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

Snackbar uses getDerivedStateFromProps() but also contains the following legacy lifecycles #10852

Closed
psamim opened this issue Mar 30, 2018 · 9 comments
Assignees
Labels
component: snackbar This is the name of the generic UI component, not the React module! v1.x

Comments

@psamim
Copy link

psamim commented Mar 30, 2018

Hi,

I get the two following errors in the console:

warning.js:33 Warning: Unsafe legacy lifecycles will not be called for components using new component APIs.

WithStyles(Snackbar) uses getDerivedStateFromProps() but also contains the following legacy lifecycles:
  componentWillReceiveProps
  componentWillUpdate
warning.js:33 Warning: Unsafe legacy lifecycles will not be called for components using new component APIs.

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

Your Environment

Tech Version
Material-UI 1.0.0-beta.39
React 16.3.0
browser Chromium 65.0.3325.181
@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 30, 2018

@psamim Thanks for raising this issue. I believe that these warnings shouldn't happen in the first place. The warnings are supposed to be suppressed:
https://github.com/reactjs/react-lifecycles-compat/blob/fd69fa09245545537caaf8b47861bab3e8549c6a/index.js#L45-L49 cc @bvaughn

I will work on #10793 today.

@bvaughn
Copy link

bvaughn commented Mar 30, 2018

withStyles uses componentWillReceiveProps itself.

@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 30, 2018

@bvaughn This logic is only here for react-hot-loader.
https://github.com/mui-org/material-ui/blob/924bc8c575b8c76f42ee7bf535778d14bcb8c21a/src/styles/withStyles.js#L118-L127
Commenting componentWillReceiveProps doesn't make the warnings go away

capture d ecran 2018-03-30 a 17 11 19

Commenting the getDerivedStateFromProps static function does.

@bvaughn
Copy link

bvaughn commented Mar 30, 2018

Gotcha. Can you point me at a repro in Code Sandbox?

@oliviertassinari
Copy link
Member

Alright, I went a bit deeper in this issue.

@psamim
Copy link
Author

psamim commented Apr 2, 2018

I am still getting the error even after updating to beta-40.

@oliviertassinari
Copy link
Member

@psamim What's the warning?

@psamim
Copy link
Author

psamim commented Apr 2, 2018

Same as before, but it is also mentioning ButtonBase

image

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 2, 2018

@psamim Follow gaearon/react-hot-loader#918

@oliviertassinari oliviertassinari added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 20, 2022
@zannager zannager added component: snackbar This is the name of the generic UI component, not the React module! v1.x and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: snackbar This is the name of the generic UI component, not the React module! v1.x
Projects
None yet
Development

No branches or pull requests

4 participants