use-on-window-scroll
Aboutβ
A React hook for adding an event listener for window scroll
Installationβ
npm install --save @rooks/use-on-window-scroll
Importing the hookβ
import useOnWindowScroll from "@rooks/use-on-window-scroll"
Usageβ
function Demo() {
useOnWindowScroll(() => console.log("window scrolled"))
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 scrollβ
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.