Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material UI: useStyles (makeStyles) has lower priority after migration to version 5

All my styles started to have lower priority in styles when I migrated to version 5 of Material Ui

const useStyles = makeStyles((theme) => ({
    drawer: {
        [theme.breakpoints.down('md')]: {
            width: 0,
        }
    },
    drawerPaper: {
        background: theme.palette.primary.main,
        width: drawerWidth,
    },
}))
like image 907
Yaroslav Shypunov Avatar asked Oct 15 '22 19:10

Yaroslav Shypunov


1 Answers

Based on official documents:

@mui/styles is the legacy styling solution for MUI. It is deprecated in v5. It depends on JSS as a styling solution, which is not used in the @mui/material anymore.

NOTE: @mui/styles is not compatible with React.StrictMode or React 18.

Instead of that, you can use The sx prop which:

is a shortcut for defining custom style that has access to the theme.

Or styled():

Utility for creating styled components.

like image 163
Majid M. Avatar answered Oct 18 '22 21:10

Majid M.