@utilityjs/use-force-rerender
v1.0.0
Published
A React hook that returns a function that will re-render your component when called.
Downloads
8
Maintainers
Readme
A React hook that returns a function that will re-render your component when called.
Useful when logic relies on state not represented in "React state".
npm i @utilityjs/use-force-rerender | yarn add @utilityjs/use-force-rerender
Usage
const Component = () => {
const forceRerender = useForceRerender();
React.useEffect(() => void DataStore.subscribe(() => void forceUpdate()), []);
return <>{DataStore.data}</>;
}
API
useForceRerender()
declare const useForceRerender: () => (() => void);