Custom React hook that listens for viewport resize events. The effect callback is called both on mount and resize.
const MyComponent = () => { useOnResize(() => { console.log('Viewport resized!'); }, []); return <div>Resize the viewport to see the effect!</div>;};
Optional
Custom React hook that listens for viewport resize events. The effect callback is called both on mount and resize.
Example