react-native-flip-card icon indicating copy to clipboard operation
react-native-flip-card copied to clipboard

Use of deprecated `componentWillReceiveProps`

Open tancredi opened this issue 6 years ago • 2 comments

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?

tancredi avatar Sep 23 '19 13:09 tancredi

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.

devstarman avatar Jan 04 '20 11:01 devstarman

@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

walidvb avatar Mar 10 '20 14:03 walidvb