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

makeStyles not found since v5.0.0-alpha.35 #27216

Closed
essuraj opened this issue Jul 10, 2021 · 17 comments · Fixed by #27466
Closed

makeStyles not found since v5.0.0-alpha.35 #27216

essuraj opened this issue Jul 10, 2021 · 17 comments · Fixed by #27466
Labels
ready to take Help wanted. Guidance available. There is a high chance the change will be accepted v5.x migration

Comments

@essuraj
Copy link
Contributor

essuraj commented Jul 10, 2021

makeStyles not found since v5.0.0-alpha.35 and no clarity on any migration strategy, the whole code base is filled with makeStyles and unsure of how to migrate them to beta, any pointers?

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

@mnajdova
Copy link
Member

This may be relevant too #20012

@siriwatknp
Copy link
Member

@essuraj if you could wait until this PR #27032 is merged. It could help reduce your migration work.

@oliviertassinari oliviertassinari changed the title makeStyles not found since alpha 35 makeStyles not found since v5.0.0-alpha.35 Jul 10, 2021
@oliviertassinari oliviertassinari added v5.x migration and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 10, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 10, 2021

no clarity on any migration strategy

Should we add these modules back in v5, with an explicit error for those that try to call them?

import MuiError from '@material-ui/utils/macros/MuiError.macro';

throw new MuiError([
  'Material-UI: x is not longer exported from @material-ui/core.',
  'You have to import it from @material-ui/styles.',
  'See https://material-ui.com/r/migration-v4/#material-ui-core-styles for more details.',
].join('\n'));

This will help the busy developers that don't have the time to read in detail the migration guide. With the link, they would find the codemod.

@essuraj

This comment has been minimized.

@mnajdova
Copy link
Member

Should we add these modules back in v5, with an explicit error for those that try to call them?

Let’s do it!

@jrhager84
Copy link

jrhager84 commented Jul 13, 2021

Consulting the docs, I am unable to import makeStyles (per docs) on v5.0.0-beta 0 | '@material-ui/styles'

How should I be importing makeStyles now?
image

@oliviertassinari
Copy link
Member

@jrhager84. Did you install @material-ui/styles@v5.0.0?

@jrhager84
Copy link

@jrhager84. Did you install @material-ui/styles@v5.0.0?

I did eventually, but the documentation is extremely nebulous about the requirements. I'm trying to find where it said, but it basically said it was broken out of /core, and unless you plan on using the themes outsides of Mui, to install the /styles package. I'll try to dig up where I saw it. I can't immediately find it presently.

@oliviertassinari oliviertassinari added the ready to take Help wanted. Guidance available. There is a high chance the change will be accepted label Jul 16, 2021
@Quozzo
Copy link

Quozzo commented Jul 19, 2021

@jrhager84. Did you install @material-ui/styles@v5.0.0?

I did eventually, but the documentation is extremely nebulous about the requirements. I'm trying to find where it said, but it basically said it was broken out of /core, and unless you plan on using the themes outsides of Mui, to install the /styles package. I'll try to dig up where I saw it. I can't immediately find it presently.

It is here were the warning specifies to install @material-ui/styles which causes issues with makeStyles since the theme is not within the same context and the theme argument comes back as an empty object.

const useStyles = makeStyles(theme => {
   console.log(theme) // {}
   return {...}
})

Installing @material-ui/styles@v5.0.0 solved the issue for me.

@alexander-larsson
Copy link

Installing @material-ui/styles@v5.0.0 solved the issue for me.

Thank god I found this. I didn't realize there was a new version of @material-ui/styles for v5.0.0. Maybe you should make this more clear in the migration guide?

@oliviertassinari
Copy link
Member

@mnajdova Maybe we shouldn't wait for a community member to take on this issue and implement #27216 (comment) now?

@jtgi
Copy link

jtgi commented Jul 24, 2021

Lost on an hour on this one 😅

Suggested documentation improvements related to the issue, on page https://next.material-ui.com/styles/basics/#installation

  1. While under the next subdomain, this should suggest installing @material-ui/styles@next, if you just install @material-ui/styles you'll pick up v4, which will silently break theming (empty theme obj, etc.).

  2. It says under a yellow sticky:
    @material-ui/styles is re-exported as @material-ui/core/styles - you only need to install it if you wish to use it independently from Material-UI. This is not true. If you are making use of makeStyles you must install @material-ui/styles.

  3. This one more of an opinion, but I believe ThemeProvider is now always required? If so, I believe this section should move up: https://next.material-ui.com/styles/basics/#using-the-theme-context.

@mnajdova
Copy link
Member

@mnajdova Maybe we shouldn't wait for a community member to take on this issue and implement #27216 (comment) now?

will do it on Monday 👍

@oliviertassinari
Copy link
Member

@jtgi Thanks for the extra feedback. It does seem that we have more improvements opportunities, 👍 for these 3 points.

@jrhager84
Copy link

Lost on an hour on this one 😅

Suggested documentation improvements related to the issue, on page https://next.material-ui.com/styles/basics/#installation

  1. While under the next subdomain, this should suggest installing @material-ui/styles@next, if you just install @material-ui/styles you'll pick up v4, which will silently break theming (empty theme obj, etc.).
  2. It says under a yellow sticky:
    @material-ui/styles is re-exported as @material-ui/core/styles - you only need to install it if you wish to use it independently from Material-UI. This is not true. If you are making use of makeStyles you must install @material-ui/styles.
  3. This one more of an opinion, but I believe ThemeProvider is now always required? If so, I believe this section should move up: https://next.material-ui.com/styles/basics/#using-the-theme-context.

This is the place I was referring to. It made it seem as though if you were using MUI, you wouldn't have to install the styles module, as you'd only have to do that if you were only using the styling.

@dandrei
Copy link

dandrei commented Aug 5, 2021

Using 5.0.0-beta.2 and I still have access to makeStyles. The legacy styling code will be completely removed by the time the stable version is released, correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to take Help wanted. Guidance available. There is a high chance the change will be accepted v5.x migration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants