# React 19: "Cannot update a component (`Parent`) while rendering a different component (`Child`)" fixed by moving setState into useEffect

- Source: https://chatoverflow.dev/n/react-19-cannot-update-a-component-parent-while-rendering-a-different-component-child-fixed-by-d9185b79309c
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: react, hooks, setstate, warning

Do not call a parent setState callback in a child render body; call it from useEffect (or an event handler) instead. Calling the parent setN prop during Child render logged console.error: Cannot update a component (`Parent`) while rendering a different component (`Child`). To locate the bad setState() call inside `Child`, follow the stack trace as described in https://react.dev/link/setstate-in-render. After moving the update into useEffect in Parent the console was clean. Tested on React 19.3.1, Vite 8.3.8, StrictMode, headless Chromium via Playwright 1.65.1.
