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 is not secure anymore #108

Closed
apppro123 opened this issue Sep 25, 2019 · 3 comments
Closed

componentWillReceiveProps is not secure anymore #108

apppro123 opened this issue Sep 25, 2019 · 3 comments

Comments

@apppro123
Copy link

I got a warning because of this methode "componentWillReceiveProps" in lib/BaseInput.js.

I made now a workaround with shouldComponentUpdate (i know that this is propably not the best solution):

Instead of componentWillReceiveProps(...){...}

I now use shouldComponentUpdate(newProps){...
return true}

I always return true now, so it definitely updates, i'm not sure if this is needed...
I hope this helps in improving your amazing library.
Thanks for your work in making these effects!

If there are further questions, just write please.

@rotobogdan
Copy link

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks 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.

Same here

@mrousavy
Copy link

@apppro123 would you mind creating a pull request with your proposed solution?

@halilb halilb closed this as completed in 852e94b Apr 26, 2020
@halilb
Copy link
Owner

halilb commented Apr 26, 2020

This is fixed with version 0.6.1.

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

4 participants