[리액트(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];
'프로그래밍(Programming) > 리액트(React)' 카테고리의 다른 글
[리액트(React) Study Log] [Person App-022] Flexible Lists (0) | 2019.01.11 |
---|---|
[리액트(React) Study Log] [Person App-021] Lists & Keys (0) | 2019.01.11 |
[리액트(React) Study Log] [Person App-019] LIsts & State (0) | 2019.01.11 |
[리액트(React) Study Log] [Person App-018] Outputting Lists (0) | 2019.01.11 |
[리액트(React) Study Log] [Person App-017] Handling Dynamic Content "The JavaScript Way" (0) | 2019.01.11 |