mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
aaede1029d
Summary: This diff removes `UNSAFE_componentWillReceiveProps` and adds the changes to `componentDidUpdate` instead. Why use `componentDidUpdate`? When reading through the [React docs on removing UNSAFE_componentWillReceiveProps](https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops), it says: > If you need to perform a side effect (for example, data fetching or an animation) in response to a change in props, use componentDidUpdate lifecycle instead. The original usage of `UNSAFE_componentWillReceiveProps` updates the content inset when `props.contentInset` changes. However, we don't always want it to update if the content inset hasn't changed, as calling `setValue` will reset the animated value unnecessarily, and kill any current animations (which we don't want to do). [React Native doc on setValue for reference](https://reactnative.dev/docs/animatedvalue#setvalue). Changelog: [General] Use componentDidUpdate instead of UNSAFE_componentwillReceiveProps in ScrollView Reviewed By: lunaleaps Differential Revision: D26487276 fbshipit-source-id: 77419deacf5db676cd721b58f34932bd6ca2399f