react——API——React.Component:setState和defaultProps

mac2022-10-07  55

1.setState() setState() 并不总是立即更新组件。它会批量推迟更新。这使得在调用 setState() 后立即读取 this.state 成为了隐患。为了消除隐患,请使用 componentDidUpdate 或者 setState 的回调函数(setState(updater, callback)

2.defaultProps

最新回复(0)