React State Handling
2021. 7. 24. 15:34ㆍReact
React에서 state을 변경할 때는 setState를 이용해야
rendering됨
componentDidMount() {
setTimeout(() => {
this.state.count = this.state.count + 1;
}, 1000);
}
동작X
componentDidMount() {
setTimeout(() => {
this.setState({
count: this.state.count + 1;
});
}, 1000);
}
동작O
'React' 카테고리의 다른 글
React Reconciliation (0) | 2021.07.30 |
---|---|
react-router-dom Redirect (0) | 2021.07.27 |
react-router-dom에서 페이지 이동시 Link component 사용 (0) | 2021.07.27 |
react-router-dom Switch component, NotFound (0) | 2021.07.27 |
Dynamic Routing에서 props 가져올 때 (0) | 2021.07.27 |