use-on-window-resize
Aboutβ
A React hook for adding an event listener for window resize
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β
Arguments | Type | Description | Default value |
---|---|---|---|
callback | function | Callback function which needs to run on unmount | undefined |
when | boolean | When the event handler should be active | true |
A React hook for adding an event listener for window resizeβ
Join Bhargav's discord serverβ
You can click on the floating discord icon at the bottom right of the screen and talk to us in our server.