useUpdateReact utility hook that returns a function that forces component to re-render when called.
import {useUpdate} from 'react-use';
const Demo = () => {
const update = useUpdate();
return (
<>
<div>Time: {Date.now()}</div>
<button onClick={update}>Update</button>
</>
);
};
// TODO: implement useUpdate function notImplemented(..._args: any[]): any { throw new Error('Not implemented'); } export default notImplemented; export const useUpdate = notImplemented;
Tests