Implement a useWindowSize hook that returns the current height and width of the window (window.innerHeight and window.innerWidth). It should re-render the component if the window size changes.
export default function Component() {const screen = useWindowSize();return (<div><p>The current window dimensions are:</p><code>{JSON.stringify(screen, null, 2)}</code></div>);}
Nothing.
The hook returns an object with the following properties:
height: number: Current height of the windowwidth: number: Current width of the windowwindow.innerHeight and window.innerWidth, not from screen.resize events and clean up the listener when the hook unmounts.window exists.