你的位置:首页 > 信息动态 > 新闻中心
信息动态
联系我们

[react] React中如何监听state的变化?

2021/11/19 4:11:54

[react] React中如何监听state的变化?

16.x 之前使用componentWillReveiveProps
componentWillReceiveProps (nextProps){
if(this.props.visible !== nextProps.visible){
//props 值改变做的事
}
}
2.16.x 之后使用getDerivedStateFromProps,16.x 以后componentWillReveiveProps也未移除

 个人简介

我是歌谣,欢迎和大家一起交流前后端知识。放弃很容易,
但坚持一定很酷。欢迎大家一起讨论





主目录

与歌谣一起通关前端面试题