State & 生命周期
State And Lifecycle
将函数组件转换成 class 组件
向 class 组件中添加局部的 state
render() {
return (
<div>
<h1>Hello, world!</h1>
<h2>It is {this.state.date.toLocaleTimeString()}.</h2>
</div>
)
}
ReactDOM.render(
<Clock />,
document.getElementById('root')
)正确地使用 State
数据是向下流动的
最后更新于