moschan / react-native-flip-card

The card component which has a motion of flip for React Native(iOS/Android)
MIT License
387 stars 112 forks source link

Use of deprecated `componentWillReceiveProps` #80

Closed tancredi closed 1 year ago

tancredi commented 4 years ago

Uses componentWillReceiveProps which is deprecated (https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops) though there should be no problem just replacing it with componentDidUpdate - thoughts?

devstarman commented 4 years ago

Is it already solved? I tried updating the package to version 3.5.5 but the warning still occurs. Also manually changing componentWillReceiveProps to componentDidMount breaks it (card is no longer flipping). My solution was to change it manually to UNSAFE_componentWillReceiveProps.

walidvb commented 4 years ago

@devstarman you'd probably want to use getDerivedStateFromProps, as componentDidMount is only run once, not when new props arrive:

From the warning message:

If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state