componentWillReceiveProps 在react17中将会被废除的,大家可以去看它在react 17 中的使用方法static getDerivedStateFromProps()
componentWillReceiveProps :
1. 首先,必须要从父组件接受参数
2. 必须要父组件的 re-render被执行
注意: 只要父组件的re-render被执行了, 子组件的这个 componentWillReceiveProps 方法就会被执行,造成不必要的性能浪费。
componentWillReceiveProps 在react17中将会被废除的,大家可以去看它在react 17 中的使用方法static getDerivedStateFromProps()
componentWillReceiveProps :
1. 首先,必须要从父组件接受参数
2. 必须要父组件的 re-render被执行
注意: 只要父组件的re-render被执行了, 子组件的这个 componentWillReceiveProps 方法就会被执行,造成不必要的性能浪费。