Do you want to request a feature or report a bug?
bug
What is the current behavior?
The following warning is being shown when using Transition.
Warning: Unsafe legacy lifecycles will not be called for components using new component APIs.
Transition uses getDerivedStateFromProps() but also contains the following legacy lifecycles:
componentWillMount
componentWillReceiveProps
The above lifecycles should be removed. Learn more about this warning here:
https://fb.me/react-async-component-lifecycle-hooks`
Reproduce
To reproduce, I am using CSSTransition with TransitionGroup on the project.
What is the expected behavior?
Should not show the Warning.
Which versions, and which browser / OS are affected by this issue? Did this work in previous versions?
Version 2.4, on Chrome. This doesn't happen in version 2.1, but I think it doesn't use the new version of react.
can you confirm that v2.4 is the actual version you have installed? we removed the deprecation methods this in v4: https://github.com/reactjs/react-transition-group/compare/v2.3.1...v2.4.0
Maybe is another dependency that may be using react-transition-group in a different version. I will check it out.
I also using Recharts and Storybook, didn't know they use react-transition-group too. They are using versions prior to v2.3.1. Thanks!
I am also getting the above message using v2.4.0. I don't have any other dependences using react-transition-group
@jquense I took a look at the compare you posted above and see that getDerivedStateFromProps() is still being used here. Maybe that is the reason for the message?
I took a look at the compare you posted above and see that getDerivedStateFromProps()
getDerivedStateFromProps is what it's supposed to be, that's the new api
@jquense my bad - I read the error message backwards. I am still getting the warning mentioned above, though for usage of componentWillMount and componentWillReceiveProps
I do see componentWillMount() used in dist/react-transition-group.js on line 951 in my node-modules, I'm guessing to polyfill for older versions of react? But I also see these flags set intended to suppress the warning message. So I would have expected the warning to be suppressed.
componentWillMount.__suppressDeprecationWarning = true;
componentWillReceiveProps.__suppressDeprecationWarning = true;
I tried doing a fresh install of node-modules and confirmed I'm installing v2.4.0
I solved this and wanted to share my solution here, in case anyone else comes looking for an answer since the warning the console was giving me was a big red-herring.
After a lot of trial and error, I discovered that react-hot-loader v4.0.0 was the cause of the issue and upgrading to atleast 4.1.1 resolved these errors.
See https://github.com/gaearon/react-hot-loader/issues/918
Most helpful comment
I solved this and wanted to share my solution here, in case anyone else comes looking for an answer since the warning the console was giving me was a big red-herring.
After a lot of trial and error, I discovered that react-hot-loader v4.0.0 was the cause of the issue and upgrading to atleast 4.1.1 resolved these errors.
See https://github.com/gaearon/react-hot-loader/issues/918