The Prompt BakeryTemplates and prompts

Fix · Pages, phones and Arabic

React state does not update the screen

What you may see

  • I change a value but the page shows the old one
  • It updates only after a second click

Most likely cause

The code changes the old object in place instead of giving React a new one, or reads the value too soon after setting it.

Check first (about two minutes)

  1. Are you changing an array or object directly (push, item.x = 1) before calling the setter?

The fix prompt

What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.

Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.

Prompt language

Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.

After you tried it, did it work?

Steps

  1. Find the state and every place that changes it.
  2. Change state by making new copies (spread, map, filter) and use the functional form when the new value depends on the old.
  3. Do not read the value right after setting it; use an effect or the value you just computed.

Do not do this

  • Do not copy state into a second state variable.
  • Do not force updates with random re-mounts.

Related

Try another entry

How can we help?

What do you need?
Your email, so we can reply (optional)Only enter your own email. We reply there.