-
Notifications
You must be signed in to change notification settings - Fork 47.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning Unsafe legacy lifecycles will not be called for components ...
keeps appearing
#12516
Comments
@eldeni can you please share an example reproducing your issue? I'm not able to reproduce the problem with your example. I suspect there's another HOC/component in your app that's causing the problem. |
Do you use some library that monkeypatches We’d need to see a reproducing example. We can’t turn off the warning: it’s intentionally there to tell you something is wrong. You need to figure out what is wrong because otherwise the code will behave in a weird way. |
@eldeni are you using react-hot-loader? gaearon/react-hot-loader#918 |
@gaearon I did use Removing Thanks @tyscorp and also @aweary console.log(this.componentWillReceiveProps) prints out
|
@OleksandrBudik Make sure you use the latest |
Since this doesn't appear to be an issue with React, I'll go ahead and close this out 🙂 If someone can provide an example reproducing the issue without any third-party libraries monkey-patching lifecycle methods, I'm happy to re-open. |
@gaearon I've upgraded to react-redux 5.0.7, but it didn't help too. It's obvious there is some 3rd party lib causing the issue, now need to check them all |
I have the same issue. It also causes serious bug alongside with warning. It seems to be a |
Do you want to request a feature or report a bug?
Might be a bug?
What is the current behavior?
Replaced componentWillReceiveProps() with a newly added getDerivedStateFromProps() but the warning keeps appearing in the console.
I doubted the higher order component at first sight, so removed all the coupling with this component's higher order wrapper. I also removed
children
in render() in an effort to remove all the side effects.Apparently there's no componentWillReceiveProps() in this component but I cannot get rid of this warning. The only thing I could do was to explicitly assign null to
this.componentWillReceiveProps
, then the warning was gone.Am I missing something or is it a bug? I also wish this warning could be optionally turned off in development environment. (Considering the legacy React libraries still use them and can be injected by e.g. HOC)
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
What is the expected behavior?
No warning (or at least to turn that off by option even in
development
environment)Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
UPDATE Apr 4
The text was updated successfully, but these errors were encountered: