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

componentWillReceiveProps raises warning #128

Closed
yilinjuang opened this issue Oct 8, 2019 · 5 comments
Closed

componentWillReceiveProps raises warning #128

yilinjuang opened this issue Oct 8, 2019 · 5 comments

Comments

@yilinjuang
Copy link

Reference: https://fb.me/react-unsafe-component-lifecycles

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 
@ahahn95
Copy link

ahahn95 commented Oct 22, 2019

@frankyjuang Seeing the same behavior when updating my React version. Did you find a solution?

@yilinjuang
Copy link
Author

@ahahn95 nope. I guess there's no way around but fix the library itself.

@gugiserman
Copy link

I just upgraded React in a couple of projects of mine and this is the last library still popping up warnings. It would be fairly easy to add the UNSAFE prefix but it's not a good long-term fix, right?

Is there any way to ignore this error temporarily so we don't have our consoles full of yellow blocks for now at least?

@maxreality
Copy link

UNSAFE will be supported throughout 17. Facebook states they have over 50k components and don't plan to end support for the lifecycle hooks instantly. However, given the activity in this repo, I think it would be wise to move your projects away from this library. In the interim, you could either try submitting a PR yourself or modifying the library and ensuring it isn't rewritten on the next npm install (dirty).

@redonkulus
Copy link
Contributor

This was fixed in #124 and released in v3.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants