React生命周期中的componentWillReceiveProps

http://reactjs.cn/react/docs/...
讲到componentWillReceiveProps的时候底下有一个注意事项
不太理解这段话的意思?
One common mistake is for code executed during this lifecycle method to assume that props have changed. To understand why this is invalid, read A implies B does not imply B implies A
There is no analogous method componentWillReceiveState. An incoming prop transition may cause a state change, but the opposite is not true. If you need to perform operations in response to a state change, use componentWillUpdate.

阅读 3.3k
1 个回答

意思是说只要上一级组件的render()发生,这个callback就会被调用。
如果props改变则会被调用 不能说明 调用的原因一定是props的改变,有可能不变。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题