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

[core] Remove withStyles from @material-ui/core #26377

Merged
merged 9 commits into from
May 25, 2021

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented May 19, 2021

BREAKING CHANGE

The withStyles JSS utility is no longer exported from @material-ui/core/styles. You can use @material-ui/styles/withStyles instead. Make sure to add a ThemeProvider at the root of your application, as the defaultTheme is no longer available. If you are using this utility together with @material-ui/core, you should use the ThemeProvider component from @material-ui/core/styles instead.

-import { withStyles } from '@material-ui/core/styles';
+import { withStyles } from '@material-ui/styles';
+import { createTheme, ThemeProvider } from '@material-ui/core/styles';

+const defaultTheme = createTheme();
 const MyComponent = withStyles((props) => {
   const { classes, className, ...other } = props;
   return <div className={clsx(className, classes.root)} {...other} />
 })(({ theme }) => ({ root: { background: theme.palette.primary.main }}));

 function App() {
-  return <MyComponent />;
+  return <ThemeProvider theme={defaultTheme}><MyComponent /></ThemeProvider>;
 }

This was the last dependency on @material-ui/styles, we can remove it now from @material-ui/core.

@mui-pr-bot
Copy link

mui-pr-bot commented May 19, 2021

Details of bundle changes (experimental)

@material-ui/core: parsed: -8.08% 😍, gzip: -8.51% 😍
@material-ui/lab: parsed: -10.02% 😍, gzip: -10.56% 😍

Generated by 🚫 dangerJS against cdfcd7c

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label May 20, 2021
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label May 21, 2021
@mnajdova mnajdova changed the title [WIP][core] Remove withStyles from @material-ui/core/styles [core] Remove withStyles from @material-ui/core/styles May 21, 2021
@mnajdova
Copy link
Member Author

Looks like failing codemods is the last issue we need to solve - https://app.circleci.com/pipelines/github/mui-org/material-ui/42518/workflows/a47a4fe4-83ea-4651-9aa3-05427294135f/jobs/254836

@oliviertassinari @mbrookes what is the expected thing here?

@mnajdova mnajdova requested a review from oliviertassinari May 21, 2021 17:17
@mnajdova mnajdova marked this pull request as ready for review May 21, 2021 17:17
@mnajdova mnajdova merged commit 697088d into mui:next May 25, 2021
@oliviertassinari oliviertassinari changed the title [core] Remove withStyles from @material-ui/core/styles [core] Remove withStyles from @material-ui/core May 29, 2021
@zannager zannager added the core Infrastructure work going on behind the scenes label Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants