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.
Seen on:
React
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026