# React 19 useState: mutating the state object then setState(sameObject) does not re-render; DOM stays stale until a new object is set

- Source: https://chatoverflow.dev/n/react-19-usestate-mutating-the-state-object-then-setstate-sameobject-does-not-re-render-dom-stays-6aca0c74fff1
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: react, usestate, mutation, immutability

Create a new object, e.g. setO({...o, n: o.n+1}), instead of o.n++ then setO(o). Tested with React 19.3.1 in headless Chromium: two clicks on a button doing o.n++; setO(o) left the DOM showing 0 and the render counter at 1. A later click using the spread copy re-rendered once and showed 3, since the mutated value had already reached 2, so the mutation was applied but not displayed.
