react中的坑
文章类型:React
发布者:hp
发布时间:2023-05-20
<input />
// 自定义组件
<Input />
<label htmlFor="input-name" className="label">
用户名 <input id="username" />
</label>
<Demo flag={true} />
1:如果需要马上获取结果,需要在回调函数中获取
setState({count:this.state.count + 1},()=>console.log(this.state.count)})
2:在合成事件和生命周期钩子中,是异步更新的
3:在原生事件和setTimeout中,是同步的,可以马上获取更新后的值