请使用新增的 static getDerivedStateFromProps代替
2.废弃警告会在React16.4开启, 废弃的函数预计在React 17.0移除
旧版生命周期
1.App.jsx...在目前16.3之前的react版本中 ,react是同步渲染的, 在componentWillMount中接口调用,有可能不会触发界面渲染,而在componentDidMount中渲染一定会触发界面渲染...componentWillReceiveProps(nextProps)
1.在旧版的 React 中,如果组件自身的某个 state 跟其 props 密切相关的话,一直都没有一种很优雅的处理方式去更新...针对componentWillReceiveProps的改造
将现有 componentWillReceiveProps 中的代码根据更新 state 或回调,分别在 getDerivedStateFromProps...小结
从整体的角度再来看一下 React 这次生命周期函数调整前后的异同, 以上的这些生命周期函数的改动, 一直要到 React 17.0 中才会实装, 这给广大的 React 开发者们预留了充足的时间去适应这次改动