We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
16.+之后版本 生命周期变更
变化: 移除了componentWillReceiveProps、componentWillUpdate、componentWillMount 添加了static getDerivedStateFromProps、getSnapshotBeforeUpdate
getDerivedStateFromProps是类的静态方法,无法使用this关键字,参数为nextProps和state,返回值为对象,与state合并,更新后的state用于render,如果不需要更新,则返回null。 官方不提倡使用derived state,建议优化组件设计,如:
getSnapshotBeforeUpdate 需要和 componentDidUpdate一起使用
The text was updated successfully, but these errors were encountered:
No branches or pull requests
16.+之后版本 生命周期变更
变化:
移除了componentWillReceiveProps、componentWillUpdate、componentWillMount
添加了static getDerivedStateFromProps、getSnapshotBeforeUpdate
getDerivedStateFromProps是类的静态方法,无法使用this关键字,参数为nextProps和state,返回值为对象,与state合并,更新后的state用于render,如果不需要更新,则返回null。
官方不提倡使用derived state,建议优化组件设计,如:
getSnapshotBeforeUpdate 需要和 componentDidUpdate一起使用
The text was updated successfully, but these errors were encountered: