useForceUpdate returns a function that forces a component to re-render by incrementing an internal counter.
Usage
Returns
() => void - A memoized function that triggers a re-render when called.
Examples
Manual Cache Invalidation
Refreshing External State
Debugging Component Updates
Working with Mutable Refs
Notes
- The returned function is memoized and stable across re-renders
- Use sparingly - most cases should use state or props instead
- Useful for integrating with non-React state management or imperative APIs
- The re-render is triggered by incrementing an internal state counter