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

Deprecated lifecycles warning when using react 16.9.0 #2680

Closed
rj-david opened this issue Aug 11, 2019 · 4 comments · Fixed by #2966
Closed

Deprecated lifecycles warning when using react 16.9.0 #2680

rj-david opened this issue Aug 11, 2019 · 4 comments · Fixed by #2966

Comments

@rj-david
Copy link
Contributor

Environment

Onsen UI Version:
2.10.10

Framework:
React 16.9.0

Framework binding:
react-onsenui 1.11.2

Platform:
All platforms

Encountered problem
React giving warnings of deprecated lifecycle methods for version 16.9.0

How to reproduce
Upgrade react to 16.9.0

@emccorson
Copy link
Contributor

I might just have my Monday head on, but I can't figure out how to see the warnings.

@rj-david Can you post the warnings as they appear for you, or give details on how exactly to get them to appear please?

Possible duplicate: #2482

@rj-david
Copy link
Contributor Author

Here is the sample error in the console:

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.

Please update the following components: Toast

I get the same error, for example, for Navigator, Page, Toolbar

The quick fix as a stop-gap just to remove the error is to rename the deprecated lifecyles: e.g. from componentWillReceiveProps to UNSAFE_componentWillReceiveProps

The long term fix is to move the handling to the other lifecyle methods.

By the way, this is indeed a duplicate. The only change now is that with React 16.9.0, React is giving that long warning for each component using the deprecated methods. For a JS developer who use the console, it makes development a little harder because I have to scroll through the long warnings.

Thanks

@rj-david
Copy link
Contributor Author

rj-david commented Sep 4, 2019

Anything we can do to help on this? We cannot move to React 16.9.0 because development will be difficult with all the warnings being thrown

@rj-david
Copy link
Contributor Author

@emccorson, created a stop-gap solution PR for React 16.9: #2694

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

Successfully merging a pull request may close this issue.

2 participants