A custom hook that returns the current window size (width and height).
const { width, height } = useWindowSize();console.log('window size:', { width, height }); Copy
const { width, height } = useWindowSize();console.log('window size:', { width, height });
The width and height are updated on window resize events. The initial values are set when the component first mounts.
An object containing the current width and height of the window.
A custom hook that returns the current window size (width and height).
Example
Remarks
The width and height are updated on window resize events. The initial values are set when the component first mounts.