1. class fields 문법 사용 (https://babeljs.io/docs/plugins/transform-class-properties/)
class Counter extends Component {
state = {
number: 0
}
}
2. class fields 사용하지 않을 때
class Counter extends Component {
constructor(props) {
super(props);
this.state = {
number: 0
}
}
}
'Web > React' 카테고리의 다른 글
Life Cycle 변화 (v16.3) (0) | 2018.05.24 |
---|---|
setState에 객체 대신 함수 전달하기 (0) | 2018.05.24 |
JSX 조건부 렌더링 (0) | 2018.05.24 |
portals (0) | 2018.05.17 |
Return Types Strings and Fragments (0) | 2018.05.17 |