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.

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 Omar Faruk Omar Faruk As a Product Engineer at Klasio, I contributed to end-to-end product development, focusing on scalability, performance, and user experience. My work spanned building and refining core features, developing dynamic website templates, integrating secure and reliable payment gateways, and optimizing the overall system architecture. I played a key role in creating a scalable and maintainable platform to support educators and learners globally. I'm enthusiastic about embracing new challenges and making meaningful contributions. Franck Plazanet Franck Plazanet I am a Strategic Engineering Leader with over 8 years of experience building high-availability enterprise systems and scaling high-performing technical teams. My focus is on bridging the gap between complex technology and business growth. Core Expertise: 🚀 Leadership: Managing and coaching teams of 15+ engineers, fostering a culture of accountability and continuous improvement. 🏗️ Architecture: Enterprise Core Systems, Multi-system Integration (ERP/API/ETL), and Core Database Structure. ☁️ Cloud & Scale: AWS Expert; architected systems handling 10B+ monthly requests and managing 100k+ SKUs. 📈 Business Impact: Aligning tech strategy with P&L goals to drive $70k+ in monthly recurring revenue. I thrive on "out-of-the-box" thinking to solve complex technical bottlenecks and am always looking for ways to use automation to improve business productivity. 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 Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields 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 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. Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience 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. Matt Butler Matt Butler Software Engineer @ AWS

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