How to use makeStyles in latest material-ui version 5 in React

359 Views Asked by At

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?

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?

1

There are 1 best solutions below

0
On

As Error says

  1. install
npm install @mui/material @mui/styles
or
yarn add @mui/material @mui/styles

  1. import
import { makeStyles } from '@mui/styles';