Skip to content
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

getDerivedStateFromProps #4354

Closed
bodrovphone opened this issue Apr 24, 2018 · 7 comments
Closed

getDerivedStateFromProps #4354

bodrovphone opened this issue Apr 24, 2018 · 7 comments

Comments

@bodrovphone
Copy link

I am getting warning with getDerivedStateFromProps in the component like:

Connect(TransactionForm) uses getDerivedStateFromProps() but also contains the following legacy lifecycles:
componentWillReceiveProps
componentWillUpdate

The above issue has been reported on react-hot-reloader but I am using create-react-app with react 16.3 and have the same one:(

Can you advise?

@gaearon
Copy link
Contributor

gaearon commented Apr 24, 2018

What version of react-redux are you using?
Please create a minimal reproducing project.

@bodrovphone
Copy link
Author

bodrovphone commented Apr 24, 2018

Thanks @gaearon for your prompt response. I am using react-redux ^5.0.7

https://github.com/bodrovphone/money-watcher/blob/master/src/components/TransactionForm.js#L46

@gaearon
Copy link
Contributor

gaearon commented Apr 24, 2018

Can you create an isolated case in CodeSandbox?

https://codesandbox.io

@bodrovphone
Copy link
Author

@gaearon sure, thanks.
Here it is:
https://codesandbox.io/s/github/bodrovphone/money-watcher

Unfortunately in sandbox the issue(warning) isn't reproducible. Here is what I got when running locally:
https://i.imgur.com/2g3EAqM.png
https://i.imgur.com/BAZiAwq.png

Any advice would be very appreciated 😀

@Tasemu
Copy link

Tasemu commented Apr 25, 2018

It appears that you are using the new lifecycle method, but also keeping OTHER legacy ones in there. If you update the others as well then you should stop getting the error.

@gaearon
Copy link
Contributor

gaearon commented Apr 25, 2018

I checked out the project locally and still can't reproduce.

screen shot 2018-04-25 at 4 15 15 pm

What's likely happening is that you have an older version of react-redux (or some other package, e.g. recompose) locally that depends on an older version of hoist-non-react-statics package. Try reinstalling node_modules.

Specifically you want to make sure you're using [email protected] (even as a transitive dependency) and not older versions.

@gaearon gaearon closed this as completed Apr 25, 2018
@bodrovphone
Copy link
Author

It helped! Thanks a lot @gaearon

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants