0.2.0 • Published 2 years ago
helpful-react-hooks v0.2.0
helpful-react-hooks
Some helpful hooks that I've found myself copying between projects
Install
npm install helpful-react-hooks
Hooks
useClickAway(callback: function, ref)
Callback function is run when the target of the click event is not a child of the ref React component
useHover(ref)
Returns true when the mouse is hovered over the ref component or one of its children, false when it is not hovered
useForceUpdate()
Returns a function that, when called, forces the component to re-render
useOnWindowResize()
Returns [winHeight, winWidth] when the browser window resizes
useSyncWithFluxStores(stores: ReduceStore<any, any>[])
Takes an array of Flux ReduceStores as input. When any of these stores are updated, the component will re-render. Useful for not having to pass store state as a prop through the parent tree.