React rerender: why forcing fails and what actually triggers it
Searching "how to force a React component to rerender" usually means something else is wrong: your UI and your state have drifted apart. React's own docs describe rendering as a three-step cycle you trigger the right way, never by force. This guide explains the cycle and the fixes, per react.dev.
Rendering is a three-step cycle
React's docs picture your components as cooks in a kitchen: trigger a render (the order goes in), render the component (the kitchen prepares it), commit to the DOM (the dish reaches the table). A "rerender" is just another trip through this cycle.
Only two things trigger a render
- The component's initial render: your app calls
createRoot(...).render(<App />)once at startup. - A state update on the component or one of its ancestors, via the setter from
useState.
That is the complete list. If your screen is stale, the honest question is "why didn't state update?", not "how do I force a refresh?"
Why forcing fails anyway
Rendering does not always produce a DOM update: React compares the new render output with the previous one and commits only the differences. A forced rerender of unchanged state changes nothing on screen, which is why force hacks feel randomly broken.
The usual real causes
- Mutating state directly (
items.push(x)) instead of calling the setter with a new array (setItems([...items, x])). React re-renders on the setter, not on silent mutation. - Data living outside state: a plain variable you change in an event handler does not trigger anything. Move it into
useStateor derive it during render. - Reading stale props after an async call: refetch or lift the state up so the update flows through the cycle.
Quick diagnosis table
| Symptom | Real cause | Fix |
|---|---|---|
| List UI not updating | Array mutated in place | Setter with a new array |
| Counter stuck | Plain variable, not state | useState |
| "Force update" hacks needed | State lives in the wrong place | Lift state up / derive during render |
Related: fetch with async/await: proper error handling for feeding your state from an API.
