componentWillReceiveProps has been renamed


#1

Hi guys. I’m getting this console message. Maybe you’re already aware of this recent change. Thanks

backend.js:6 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • 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
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

#2

Hi Marcos, actually RS is not utilizing componentWillReceiveProps for anything at the moment. For me it looks like the warning is coming from backend.js package. Would you be able to try to increase the backend.js package version number in case they have already done the necessary changes to solve the issue?


#3

Hi Juha. Makes sense. I’ll check, thank you


#4

Hi Juha. I was trying to understand Antti’s exemple and I found the “componentWillReceiveProps”


#5

Yes, we need to get rid of it at some point. We aren’t using it for anything anymore so it shouldn’t cause problems.