p5.js-web-editor/client/components/useAsModal.jsx

11 lines
306 B
React
Raw Normal View History

import React from 'react';
import { useModalBehavior } from '../utils/custom-hooks';
export default (component) => {
const [visible, trigger, setRef] = useModalBehavior();
const wrapper = () => <div ref={setRef}> {visible && component} </div>; // eslint-disable-line
return [trigger, wrapper];
};