VibeDict

🧩Tried to change another component while drawing

What you'll see
Cannot update a component while rendering a different component

React warned you because the code tried to change another component's value while it was still drawing the screen.

🤔 Why does it happen?

  • The parent's setState was called directly in the component's body
  • Code that runs during drawing changed a different state

🔧 Try this

  1. Move the code that changes values into an event (like a button click) or into useEffect
  2. Check the two component names shown in the error

🤖 Ask your AI like this

React shows the warning 'Cannot update a component while rendering a different component'. Please find where state is changed during rendering and move it into an event or useEffect. [Paste the full error here]

Replace the [ ] parts with your own situation, and paste the error with a few extra lines before and after it.

Related terms

Other errors in this group