Cannot update a component while rendering another component

React ErrorLifecycle ErrorCommonLast updated: June 28, 2026Tested on:React v19.0Next.js 16June 2026

A child component schedules a state update on its parent during the render phase.

Cannot update a component while rendering another component Quick Fix⏱️ Est. Fix Time: 3–8 minutes

Usually happens because:

  • Child component executes parent setter on render
  • Context updates triggered inside render body
  • Redux dispatch executed directly in function component

🔍 Quick Checklist:

📊 Where this usually happens (estimated occurrence)

Child updating parent in render body65%
Context dispatch on render25%
Redux dispatch on render10%

What is Cannot update a component while rendering another component?

This warning occurs when a component executes a function that updates the state of another component (usually a parent component via callback props) during its own render phase. React enforces unidirectional data flow and blocks side-effects from running during rendering.

Common Causes

  • Calling parent state setters directly inside the body of a rendering child component.
  • Triggering context updates inside child component definitions.

Common Mistakes

  • Updating Context variables unconditionally inside child component render methods.

How to Fix

1Move state updates into useEffect hooks inside the child component.
2Trigger parent updates from events (like button clicks) rather than on render.

Framework-Specific Examples

No framework examples required for this informational status.

Wrong: Parent State set in Render

HTTP Request
function Child({ onRender }) {
  onRender(); // parent setter called during child rendering
  return <div>Child</div>;
}

Correct: Parent State set in useEffect

HTTP Response
import { useEffect } from 'react';

function Child({ onRender }) {
  useEffect(() => {
    onRender(); // called safely after mount/render phases complete
  }, [onRender]);

  return <div>Child</div>;
}

Best Practices

  • Verify child components only read properties during rendering and trigger modifications inside effects or actions.

Frequently Asked Questions (FAQ)

Q: Why does React block updates during rendering?

Rendering must be a pure function of props and state. Side effects (like scheduling updates on other components) during render break predictability and trigger rendering errors.

Q: How does using useEffect fix this?

useEffect runs after the active render cycle is complete and the layout is painted to the DOM, allowing React to schedule new updates safely.

Q: Can Redux dispatch calls cause this error?

Yes. Dispatching actions inside the render body of a component triggers state changes, raising the same warning.

Q: Does this warning crash my production application?

No. It is a console warning in development, but it indicates poor lifecycle implementation and can lead to unexpected UI glitches.

Still having this problem?

Didn't solve your problem?

SuggestRequest Error