Warning: Cannot update a component (`Parent`) while rendering a different component (`Child`)
A child component updated a parent’s state during its render instead of in an effect or event handler.
Cannot update a componentwhile rendering a different component Meaning
Calling a parent’s setState (or a context/store setter) in the body of a child render causes this warning and can cause loops.
Common causes
- Calling onChange/setState props directly in render
- Store/context updates in render
- Syncing derived state during render
⚡ Quick fix
- Move the update into useEffect or an event handler
- Derive values instead of syncing state
Detailed fix by platform
React
useEffect(() => { onLoaded(items.length); }, [items.length, onLoaded]);
How to diagnose
- Components — Which parent/child are named?
- Call — Where is the setter called?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Actions must be plain objects Error: Actions must be plain objects. Instead, the actual type was: 'function'.
- Could not Fast Refresh [vite] hmr invalidate … Could not Fast Refresh. Export is incompatible.
- Dynamic server usage Error: Dynamic server usage: Route /x couldn't be rendered statically because it used `cookies`
Most viewed in React
- React must be in scope ReferenceError: React is not defined / 'React' must be in scope when using JSX
- Objects are not valid as a React child Error: Objects are not valid as a React child
- Functions cannot be passed Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server".
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 12 Oct 2026