类型错误:无法读取未定义的属性(读取“向下”)

Hei*_*Zin 3 reactjs material-ui

我创建了一个标题菜单。它在 Material-UI V4 中仍然有效。但我最近更新到了 Material-UI V5。但我有这样的错误: TypeError: Cannot readproperties of undefined (reading 'down')

import makeStyles from "@mui/styles/makeStyles";
import { Theme } from "@mui/system";

// NOTE: Styling header bar components

const useStyles = makeStyles((theme: Theme) => ({
    title: {
        flexGrow: 1,
    },
    linkStyle: {
        textDecoration: "none",
        color: "white",
        marginLeft: 5,
    },
    desktopMenuStyle: {
        display: "display",

        [theme.breakpoints.down("mobile")]: {
            display: "none",
        },
    },
    mobileMenuStyle: {
        display: "none",

        "& .MuiList-root": {
            marginTop: 40,
        },
        [theme.breakpoints.down("laptop")]: {
            display: "block",
        },
    },
}));
Run Code Online (Sandbox Code Playgroud)

我有这样的错误

小智 5

将此代码写入包含您的组件的文件中。

1.进口:

import { ThemeProvider } from "@mui/styles";

import { createTheme, responsiveFontSizes } from '@mui/material/styles';
Run Code Online (Sandbox Code Playgroud)
let theme = createTheme();
theme = responsiveFontSizes(theme);
Run Code Online (Sandbox Code Playgroud)
<ThemeProvider theme={theme}>
  <your component/>
</ThemeProvider>
Run Code Online (Sandbox Code Playgroud)