[리액트(React) Study Log] [Person App-020] Updating State Immutably


 - state(object) immutablilty 를 유지하면서 다루는 방법 : state 자체가 아니라 state copy 해서 사용

 - object copyt 하는 방법 slice 또는 spread operator(전개연산자: ...) 를 사용.

// DO NOT USE : const persons = this.state.persons;

// const persons = this.state.persons.slice();

const persons = [...this.state.persons];

 


+ Recent posts