生命周期
页面初始化
constructor
- componentWillMount(待废弃,用UNSAFE_前缀)
render
- componentDidMount
更改state
- getDerivedStateFromProps(新)
返回null继续更新,否则修改state的值影响后续流程
- shouldComponentUpdate
返回true继续更新,返回false停止更新
- componentWillUpdate(待废弃,用UNSAFE_前缀)
render
- getSnapshotBeforeUpdate(新)
方法参数为:prevProps,prevState
返回null继续执行
- componentDidUpdate
<br />
组件卸载前
- componentWillUnmount
网友评论