UNPKG

phx-react

Version:

PHX REACT

23 lines 739 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useWindowWidth = void 0; const react_1 = require("react"); const useWindowWidth = () => { const [width, setWidth] = (0, react_1.useState)(() => { if (typeof window === 'undefined') return 0; return window.innerWidth; }); (0, react_1.useEffect)(() => { const handleResize = () => { setWidth(window.innerWidth); }; window.addEventListener('resize', handleResize); return () => { window.removeEventListener('resize', handleResize); }; }, []); return width; }; exports.useWindowWidth = useWindowWidth; //# sourceMappingURL=use-window-width.js.map