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

Alert.js is importing withStyles from wrong file. #28259

Closed
alucardu opened this issue Sep 10, 2021 · 4 comments
Closed

Alert.js is importing withStyles from wrong file. #28259

alucardu opened this issue Sep 10, 2021 · 4 comments
Labels
status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@alucardu
Copy link

alucardu commented Sep 10, 2021

I'm trying to use the Material ui snackbar and alerts but the browser is showing an error:

withStyles.js?1e4f:3 Uncaught Error: Material-UI: withStyles is not longer exported from @material-ui/core/styles.
You have to import it from @material-ui/styles.

Alert.js is doing this:

import { withStyles, lighten, darken } from '@material-ui/core/styles';
  • [x ] The issue is present in the latest release.
  • [x ] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Application compiles without issue, but shows error in browser.

Expected Behavior 🤔

Shouldn't show an error.

Steps to Reproduce 🕹

https://codesandbox.io/s/gifted-forest-ztng7

Your Environment 🌎

`System: OS: Windows 10 10.0.19042 Binaries: Node: 14.17.6 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: Not Found Edge: Spartan (44.19041.1023.0), Chromium (93.0.961.38) npmPackages: @emotion/react: ^11.4.1 => 11.4.1 @emotion/styled: ^11.3.0 => 11.3.0 @mui/core: 5.0.0-alpha.46 @mui/material: ^5.0.0-rc.1 => 5.0.0-rc.1 @mui/private-theming: 5.0.0-rc.1 @mui/styled-engine: 5.0.0-rc.1 @mui/system: 5.0.0-rc.1 @mui/types: 7.0.0-rc.1 @mui/utils: 5.0.0-rc.1 @types/react: ^17.0.20 => 17.0.20 react: ^17.0.2 => 17.0.2 react-dom: ^17.0.2 => 17.0.2 typescript: ^4.3.5 => 4.3.5`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Manually changing the line in node_modules\@material-ui\lab\esm\Alert\Alert.js to import { withStyles, lighten, darken } from '@material-ui/styles'; fixes the issue, but that's obviously not the wanted solution.

@alucardu alucardu added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 10, 2021
@eps1lon
Copy link
Member

eps1lon commented Sep 10, 2021

You're using an incompatible version of the /lab or /material package. Using the latest versions of both, works as expected: https://codesandbox.io/s/hungry-currying-r09j0?file=/src/Demo.tsx

@eps1lon eps1lon closed this as completed Sep 10, 2021
@eps1lon eps1lon added status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 10, 2021
@alucardu
Copy link
Author

alucardu commented Sep 10, 2021

@eps1lon You're right, I was using "@material-ui/lab": "^4.0.0-alpha.60", which is installed when yarn add @material-ui/lab I can't find any references to a new version of @material-ui/lab @material-ui/lab@next in any of the documents though.

@mnajdova
Copy link
Member

@alucardu you should use the next version for each of the packages, or even better upgrade to the new package names. See #28049

@alucardu
Copy link
Author

Cheers, I'm just pointing out I couldn't find this in any of the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

3 participants