Hook
1. Class Component์ Function Component
Class Component
class Counter extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0
}
this.handleIncrease = this.handleIncrease.bind(this);
}
handleIncrease = () => {
this.setState({
counter: this.state.counter + 1
})
}
render(){
return (
<div>
<p>You clicked {this.state.counter} times</p>
<button onClick={this.handleIncrease}>
Click me
</button>
</div>
)
}
}Function Component
2. Hook์ด๋?
3. Hook ์ฌ์ฉ ๊ท์น
1. ๋ฆฌ์กํธ ํจ์์ ์ต์์์์๋ง ํธ์ถํด์ผ ํจ
2. ์ค์ง ๋ฆฌ์กํธ ํจ์ ๋ด์์๋ง ์ฌ์ฉ๋์ด์ผ ํจ
Last updated