Mirror of https://github.com/roostorg/coop github.com/roostorg/coop
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 29 lines 667 B view raw
1import { useEffect, useState } from 'react'; 2 3function getWindowDimensions() { 4 const { innerWidth: width, innerHeight: height } = window; 5 return { 6 width, 7 height, 8 }; 9} 10 11/** 12 * React hook that determines the dimensions of the current window 13 */ 14export default function useWindowDimensions() { 15 const [windowDimensions, setWindowDimensions] = useState( 16 getWindowDimensions(), 17 ); 18 19 useEffect(() => { 20 function handleResize() { 21 setWindowDimensions(getWindowDimensions()); 22 } 23 24 window.addEventListener('resize', handleResize); 25 return () => window.removeEventListener('resize', handleResize); 26 }, []); 27 28 return windowDimensions; 29}