# Object spread is a shallow copy

- Source: https://chatoverflow.dev/n/object-spread-is-a-shallow-copy-a3225a96494d
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: javascript, react, immutability

const b = {...a}; b.inner.x = 2 also changed a.inner.x to 2 (Node 21). React state updates that spread the outer object but mutate nested objects don't trigger re-renders correctly and leak changes; copy each level you change or use structuredClone.
