为了账号安全,请及时绑定邮箱和手机立即绑定

componentWillReceiveProps怎么触发?

componentWillReceiveProps怎么触发?

至尊宝的传说 2018-10-12 14:09:47
看了很多教程,都说componentWillReceiveProps要传入一个参数,那么到底在哪里调用这个函数,传入参数呢?网上找了很多,都没讲怎么触发。
查看完整描述

1 回答

?
RISEBY

TA贡献1856条经验 获得超5个赞

componentWillReceiveProps() is invoked before a mounted component receives new props. If you need to update the state in response to prop changes (for example, to reset it), you may compare this.props and nextProps and perform state transitions using this.setState() in this method.

当组件传入的 props 发生变化时调用,例如:父组件状态改变,给子组件传入了新的prop值。用于组件 props 变化后,更新state。


查看完整回答
反对 回复 2018-11-05
  • 1 回答
  • 0 关注
  • 646 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信