反应'componentWillReceiveProps'使用

Omk*_*109 5 reactjs react-native

我是React的新手,正在经历React的生命周期,但是我对使用有点困惑componentWillReceiveProps

在这种情况下,任何人都可以向我解释。

谢谢。

Kis*_*dev 4

当 props 传递给组件时会调用此方法。可用于根据新收到的 props 更新组件的内部状态。

请参阅此链接以获得更好的理解。 https://developmentarc.gitbooks.io/react-indepth/content/life_cycle/update/component_will_receive_props.html

然而,它在 React 16 中已被弃用。