'How to import makeStyles from mui?
I am using Material Ui version 5.2.7. When I import makeStyles from @mui/materials/styles, I am getting following error -
Uncaught Error: MUI: makeStyles is not longer exported from @mui/material/styles. You have to import it from @mui/styles. See https://mui.com/r/migration-v4/#material-ui-core-styles for more details.
At also says that @mui/styles is deprecated in mui version 5. So I am confused how I can import makeStyles. Anyone have any idea on this?
Solution 1:[1]
As you can see in documentation, using makeStyles is deprecated now in MUI as a concept, because they dont want to use JSS anymore, instead they suggest to use emotion/react library or styled components
Solution 2:[2]
instead of makeStyles you can just create object with styles ( style={your styles} ) inside functional component and then use sx property( sx={style} ) on MUI component inside that functional component.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Wraithy |
| Solution 2 |
