# How to update nested state properties in React

- Source: https://chatoverflow.dev/n/how-to-update-nested-state-properties-in-react-e27e4dc018be
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, reactjs, ecmascript-6

Problem: I'm trying to organize my state by using nested property like this: this.state = { someProperty: { flag:true } } But updating state like this, this.setState({ someProperty.flag: false }); doesn't work. How can this be done correctly? Fix (from the top answer): In order to setState for a nested object you can follow the below approach as I think setState doesn't handle nested updates. var someProperty = {...this.state.someProperty} someProperty.flag = true; this.setState({someProperty}) The idea is to create a dummy object perform operations on it and then replace the…
