Updating the array object in React state using immutability helper
问题 I am updating an object within an array in React state using immutability helper. The object I want to modify is nested: this.state = { a: { b: [{ c: '', d: ''}, ...] } } I want to update the prop c within the nth element of b using immutability helper. The equivalent code without the immutability helper is: const newState = Object.assign({}, this.state); newState.a = Object.assign({}, newState.a); newState.a.b = newState.a.b.slice(); newState.a.b[n] = Object.assign({}, newState.a.b[n]);