Bolt ui

React State Not Updating - Component Doesn't Re-render

You update React state with setState() or useState hook, but the component doesn't re-render. The state seems to update in DevTools but the UI doesn't change.

This happens with objects and arrays particularly.

Error Messages You Might See

State updates but component doesn't re-render OldValue shown in UI but state shows newValue Object mutation warning in strict mode
State updates but component doesn't re-renderOldValue shown in UI but state shows newValueObject mutation warning in strict mode

Common Causes

  1. Mutating state directly instead of creating new reference: state.obj.prop = newValue (WRONG)
  2. Not creating new array/object: setState([...state, item]) works, state.push(item) doesn't
  3. Setting state to same reference (React sees no change): setState(state)
  4. Async state update where component unmounts before update
  5. setState in useCallback without dependency causing stale closures

How to Fix It

Always create new references: setState({...state, key: newValue}) for objects

For arrays: setState([...state, newItem]) or setState(state.filter(...))

Use immutable patterns: setState(prev => ({...prev, key: value}))

Check DevTools - if state actually updates but UI doesn't, it's an immutability issue

For complex state: consider useReducer for clearer intent

Real developers can help you.

Jacek Rozanski Jacek Rozanski Senior PHP/Symfony developer and DevOps engineer with 20+ years of professional experience, running opcode.pl (web development agency, est. 2004). Day job: I'm the sole backend developer at merketing company where I own and maintain 11 PHP/Symfony microservices on AWS (ECS Fargate, RDS, S3, CloudFront), handle the full CI/CD pipeline (Bitbucket Pipelines, Docker), and manage monitoring with Sentry and CloudWatch. These services handle high request volumes in production every month. What I bring to AI-built apps: - I audit and fix security issues (OWASP methodology), performance bottlenecks, and architectural problems in codebases generated by Cursor, Claude Code, Lovable, Bolt, and v0 - I refactor AI-generated prototypes into production-grade applications with proper error handling, testing, and clean architecture (SOLID, DDD, hexagonal architecture) - I set up the infrastructure AI tools don't touch: AWS hosting, CI/CD pipelines, automated deployments, database optimization, monitoring, and alerting - I integrate external services: payment providers, email systems, partner APIs, SSO/auth Tech stack: PHP 8.x, Symfony, React, Next.js, PostgreSQL, MySQL, Docker, AWS (ECS, RDS, S3, SQS/SNS, CloudFront), Terraform, Supabase. I also use AI tools daily (Claude Code, Cursor) in my own workflow, so I understand both the strengths and the gaps in AI-generated code. Based in Poland (CET timezone). Available for async work and calls during EU/US business hours. Nam Tran Nam Tran 10 years as fullstack developer rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job. Taufan Taufan I’m a product-focused engineer and tech leader who builds scalable systems and turns ideas into production-ready platforms. Over the past years, I’ve worked across startups and fast-moving teams, leading backend architecture, improving system reliability, and shipping products used by thousands of users. My strength is not just writing code — but connecting product vision, technical execution, and business impact. Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure AUXLE AUXLE I am a Full Stack Developer experienced in building Websites, Web apps and Cross Platform Mobile Apps for Startups and Companies. Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools. Anthony Akpan Anthony Akpan Developer with 8 years of experience building softwares fro startups

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

Why doesn't setState work with objects?

React compares references. If you mutate the same object, it looks unchanged. Create new reference: {...state, prop: value}

What's the difference between setState(state) and setState({...state})?

setState(state) doesn't trigger re-render because reference didn't change. setState({...state}) creates new reference

Should I always use ...state?

Yes, when you're changing properties. For full replacement, setState(completeNewValue) is fine

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help