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

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.

Nam Tran Nam Tran 10 years as fullstack developer Matthew Butler Matthew Butler Systems Development Engineer @ Amazon Web Services Sage Fulcher Sage Fulcher Hey I'm Sage! Im a Boston area software engineer who grew up in South Florida. Ive worked at a ton of cool places like a telehealth kidney care startup that took part in a billion dollar merger (Cricket health/Interwell health), a boutique design agency where I got to work on a ton of exciting startups including a photography education app, a collegiate Esports league and more (Philosophie), a data analytics as a service startup in Cambridge (MA) as well as at Phillips and MIT Lincoln Lab where I designed and developed novel network security visualizations and analytics. I've been writing code and furiously devoted to using computers to make people’s lives easier for about 17 years. My degree is in making computers make pretty lights and sounds. Outside of work I love hip hop, the Celtics, professional wrestling, magic the gathering, photography, drumming, and guitars (both making and playing them) MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help 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. Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well. Jen Jacobsen Jen Jacobsen I’m a Full-Stack Developer with over 10 years of experience building modern web and mobile applications. I enjoy working across the full product lifecycle — turning ideas into real, well-built products that are intuitive for users and scalable for businesses. I particularly enjoy building mobile apps, modern web platforms, and solving complex technical problems in a way that keeps systems clean, reliable, and easy to maintain. Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system.

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