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.

zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure 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 Mehdi Ben Haddou Mehdi Ben Haddou - Founder of Chessigma (1M+ users) & many small projects - ex Founding Engineer @Uplane (YC F25) - ex Software Engineer @Amazon and @Booking.com Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Nam Tran Nam Tran 10 years as fullstack developer

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