useUpdate
React utility hook that returns a function that forces component to re-render when called
Usage
Live Editor
function Demo() { const update = useUpdate(); return ( <> {/* to avoid ssr error beacause date.now() will not be same in server and client */} <div suppressHydrationWarning={true}>Time: {Date.now()}</div> <button onClick={update}>Update</button> </> ); };
Result
Loading...
API
useUpdate
Returns
() => void
: rerender trigger function