Material-UI makeStyles cannot read property 'down' of undefined
Replace
import { makeStyles } from "@material-ui/styles";
with
import { makeStyles } from "@material-ui/core/styles";
makeStyles
from "@material-ui/core/styles"
is a wrapper hook of the other one. This wrapper add a default theme if you don't provide one in ThemeProvider
. Source.
MUI - makeStyles - Cannot read properties of undefined
Since you're using v5, change your ThemeProvider
, createTheme
and makeStyles
import path from:
import { ThemeProvider, createTheme, makeStyles } from "@material-ui/core/styles";
To:
import { ThemeProvider, createTheme } from "@mui/material/styles";
import { makeStyles } from "@mui/styles";
@material-ui/core
is v4 package and @mui/material
is the v5 equivalent. The API from the 2 versions are not compatible. In v5, makeStyles
is also moved to a legacy package called @mui/styles
, if you are using MUI v5 in a new project, you should switch completely to styled
/sx
API as recommended by the MUI team.
Related answers
- Difference between @mui/material/styles and @mui/styles?
- Cannot use palette colors from MUI theme
- MUI createTheme is not properly passing theme to MUI components
MaterialUI 5 : TypeError: Cannot read properties of undefined (reading 'create')
Just ran into this myself. You can import createTheme
from @mui/material/styles
or @mui/system
, but they do slightly different things:
You can use the utility coming from the
@mui/system
package, or if you are using@mui/material
, you can import it from@mui/material/styles
. The difference is in the defaulttheme
that is used (if no theme is available in the React context).
The one from @mui/material/styles
is smart enough to fill in gaps in the active theme from the default MUI theme. So if you're using @mui/material
, then use @mui/material/styles
.
I am getting (TypeError: Cannot read property 'down' of undefined)
maybe try replacing
import { makeStyles } from "@material-ui/styles";
with
import { makeStyles } from "@material-ui/core/styles";
MUI error: Cannot read properties of undefined (reading 'drawer')
It's strange but solution is reinstalling all MUI packages
Related Topics
How to Target CSS Class Names That Start with Digit
How to Repeat a CSS Grid Layout Pattern
Can You Float a Div in the Lower Right of Its Parent Div and Have Text Wrap Around It
Why the :Before and :After Pseudo-Elements Work Only in Firefox
Img with {Display: Table-Cell} -- Is It a Bug
How to Animate a Svg Figure Like a Progress Bar with CSS
How to Code an Arrow Using CSS
Applying CSS on Drawn Canvas Elements
Material-Ui Makestyles Cannot Read Property 'Down' of Undefined
Apply Blur Effect to Parent Container Only
Grid Item 100% Height of Parent
CSS Two Columns with Known Children Width
How Do Browsers Deal with "Tofu" Characters
How to Route to CSS/Js Files in MVC.Net
Vertical Margins Disappear When Parent Is Set to Overflow:Visible