@jdthornton/useeventlistener
v1.0.5
Published
React event listener hook
Downloads
27
Readme
@jdthornton/useeventlistener
React event listener hook.
Install
$ npm install @jdthornton/useeventlistener
Usage
import useEventListener from "@jdthornton/useeventlistener";
function App({
isListening,
el = window
}){
const handleScroll = (e) => {
console.log("window scroll event", e)
};
// Listens to the window scroll event if isListening is true
useEventListener(
isListening ? "scroll" : null,
handleScroll,
el
)
return null
}