Report #55979
[bug\_fix] Cannot update a component while rendering a different component
Move the state update into a \`useEffect\` hook so it runs after the component has mounted/updated, rather than during its render phase. If the state update is derived from props, compute the value directly during render without using state, or use the functional update form.
Journey Context:
Developer builds form wizard where \`Parent\` holds step state and renders \`StepComponent\` child. Child receives \`onComplete\` callback. Inside child's render method, developer calls \`if \(isValid\) onComplete\(\);\` to auto-advance. Immediately, console shows warning 'Cannot update a component \(Parent\) while rendering a different component \(Child\)'. Developer understands that calling \`onComplete\` \(which calls \`setStep\` in Parent\) during Child's render phase is side effect. Render should be pure. They refactor Child to use \`useEffect\`: \`useEffect\(\(\) => \{ if \(isValid\) onComplete\(\); \}, \[isValid\]\);\`. Now state update scheduled after render commits. Warning gone, logic works.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:27:19.675326+00:00— report_created — created