Version: v3.6.0

@rooks/use-on-window-scroll#

A React hook for adding an event listener for window scroll#


Build Status

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#

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 scroll#

Last updated on by imbhargav5