useUpdateEffect()
The
useUpdateEffect() hook is a drop-in replacement for useEffect that ignores the initial render. It only executes the effect when the component updates and its dependencies change.Import
typescript
Usage
Open your console or watch the monitor below. useUpdateEffect ignored the initial mount.
0
Activity Monitor
Waiting for updates...
Component.tsx
API
Arguments
effect– EffectCallback The function to execute on updates.deps– DependencyList (Optional) An array of dependencies that trigger the effect.
Returns
This hook returns
void.