Skip to main content
Version: v3.6.0

@rooks/use-on-window-resize

A React hook for adding an event listener for window resize​


Build Status

Installation​

npm install --save @rooks/use-on-window-resize

Importing the hook​

import useOnWindowResize from "@rooks/use-on-window-resize"

Usage​


function Demo() {
useOnWindowResize(() => console.log("window resized"))
return <p> Hello world </p>
}

render(<Demo/>)

Arguments​

ArgumentsTypeDescriptionDefault value
callbackfunctionCallback function which needs to run on unmountundefined
whenbooleanWhen the event handler should be activetrue

A React hook for adding an event listener for window resize​