import {useEffect, useRef, useState} from 'react'; import Dom from '@/react/components/dom.jsx'; import {RESOLUTION} from '@/util/constants.js'; function Decorator({children, style}) { const ref = useRef(); const [scale, setScale] = useState(0); useEffect(() => { if (!ref.current) { return; } function onResize() { const {parentNode} = ref.current; const {width} = parentNode.getBoundingClientRect(); setScale(width / RESOLUTION.x); } window.addEventListener('resize', onResize); onResize(); return () => { window.removeEventListener('resize', onResize); } }, [ref.current]); return (
{children}
); } export default function(options = {}) { return function decorate(Decorating) { return ( ); }; }