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

Warning: componentWillMount has been renamed, and is not recommended for use #17445

Closed
1 task done
kjhughes opened this issue Sep 16, 2019 · 3 comments
Closed
1 task done
Labels
external dependency Blocked by external dependency, we can’t do anything about it

Comments

@kjhughes
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

Eliminate use of deprecated legacy React component lifecycles such as componentWillMount.

Examples 🌈

react@16.9.0
material-ui/core@4.4.2

react-dom.development.js:12029 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: Animate, Line, LineChart, Text
printWarning @ react-dom.development.js:12029

Motivation 🔦

See official Reactjs.org motivation described in Update on Async Rendering article.

@Bouncue
Copy link

Bouncue commented Sep 16, 2019

I also get dozens warning like this, is this warning come from Material-UI? I thought it was came from other dependencies of mine, because as far as I know Material-UI has already been migrated its code base to hooks so unlikely they still use componentWillMount

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 16, 2019

Please update the following components: Animate, Line, LineChart, Text

We have migrated the codebase 6 months ago. These warnings don't come from us.

@oliviertassinari oliviertassinari added the external dependency Blocked by external dependency, we can’t do anything about it label Sep 16, 2019
@kjhughes
Copy link
Author

Oh, sorry, you're right: Real culprit is actually the external dependency on recharts, which is used in material-ui's Dashboard template.

Recharts has an associated open issue: recharts/recharts#1835

Thanks, @oliviertassinari !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external dependency Blocked by external dependency, we can’t do anything about it
Projects
None yet
Development

No branches or pull requests

3 participants