maisano / react-router-transition

painless transitions built for react-router, powered by react-motion
http://maisano.github.io/react-router-transition/
MIT License
2.59k stars 139 forks source link

componentWillReceiveProps is going to be deprecated #109

Closed nightspirit closed 4 years ago

nightspirit commented 4 years ago

React is going to deprecate componentWillReceiveProps in version 17 which will affect AnimatedSwitch.

Do you have any plan to fix it?

I am not sure if you move the affected code into "componentDidUpdate" will cause any other trouble. There is another way "getDerivedStateFromProps" but that will force people to have react 16.3.0+ as peer dependency.

iMerica commented 4 years ago

The author of this project appears to be MIA. Feel free to use my fork in the interim.

yarn add iMerica/react-router-transition.

maisano commented 4 years ago

@nightspirit Thanks for opening this. I haven't used this package in a while, and as such have not been doing a great job keeping it in sync with the latest versions of React. I'm happy to accept a PR that switches componentWillReceiveProps to getDerivedStateFromProps if anyone wants to take that work on. I think it would be fine to cut to a newer version which enforced later versions of React for this.

Otherwise, I can try to get to this over the next couple days.

maisano commented 4 years ago

I plan on merging #110 fairly soon. While it is a bigger departure from marking this lifecycle method with UNSAFE_, it seemed like a good opportunity to revisit this package and update it to use hooks.

maisano commented 4 years ago

This has been solved by #110 – let me know if you have any other concerns.

harleylang commented 3 years ago

@maisano I am receiving a similar message:

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.

Please update the following components: TransitionMotion