question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[@mui/styles] Regression accessing theme

See original GitHub issue

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Hello.

I found a regression on the latest versions of @mui/styles.

https://codesandbox.io/s/mui-styles-regression-peisqv

In the above sandbox, you can see the text has the same color as the Button.

If I increase @mui/styles from 5.2.3, the text is not the same color anymore because the theme is not passed to my components. You can see the console.log in the console.

I also needed to decrease the version of @mui/material to 5.2.8.

Expected behavior 🤔

The Theme should be passed to my components with the latest versions of @mui/styles and @mui/material.

Steps to reproduce 🕹

Steps:

  1. Go to the sandbox https://codesandbox.io/s/mui-styles-regression-peisqv
  2. Increase @mui/styles or @mui/material version
  3. See the text in red

Context 🔦

I’m migrating an old project to @mui v5 but it’s not possible to update all my components to styled components.

So I have to keep makeStyles.

Following the documentation, the makeStyles is not working in recent versions.

Thanks

Your environment 🌎

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
FlorianBurgevincommented, Apr 12, 2022

@mnajdova it seems to work if I fix all my versions.

Thank you.

1reaction
mnajdovacommented, Apr 11, 2022

@FlorianBurgevin looks a lot like a mismatch in the versions. Both @mui/styles and @mui/material depend on @mui/private-theming which is a package providing the react context for the theme. If the versions end up using different version of this package, they basically depend on different react context, which would result on something similar as what you’ve pointed out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Theming - Material UI - MUI
Customize MUI with your theme. You can change the colors, the typography and much more. The theme specifies the color of the components,...
Read more >
Theme is empty in makeStyles for @mui/styles as compared to ...
The issue here is that you're importing your ThemeProvider from @mui/material/styles . In order for the theme object to be populated ...
Read more >
@material-ui/styles | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Theme UI
Theme UI is a library for creating themeable user interfaces based on constraint-based ... This project is using Percy.io for visual regression testing....
Read more >
Material UI: Create a Custom Toggle Theme using React Hooks
Create a theme using Material UI's createMuiTheme() and override the palette ... Material UI's default styles using the className property.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found