在MUI v5.14.13中,一切运行正常,突然我开始收到以下错误:

MUI: The value found in theme for prop: "error" is an [Object] instead of string or number. Check if you forgot to add the correct dotted notation, eg, "background.paper" instead of "background". 

看起来像是来自style.js:34号档案.尽管该组件中没有直接使用样式化组件,但我收到了上面的错误消息.

Here is an example

下面的代码将全屏启动一个对话框并在单击Cancel时将其关闭:

import * as React from "react";
import Dialog from "@mui/material/Dialog";
import AppBar from "@mui/material/AppBar";
import Toolbar from "@mui/material/Toolbar";
import IconButton from "@mui/material/IconButton";
import CloseIcon from "@mui/icons-material/Close";
import Slide from "@mui/material/Slide";
import { Box, Button, Stack } from "@mui/material";

const Transition = React.forwardRef(function Transition(props, ref) {
  return <Slide direction="up" ref={ref} {...props} />;
});

const FullScreenDialog = ({ open, onClose }) => {
  return (
    <div>
      <Dialog
        fullScreen
        open={open}
        onClose={onClose}
        TransitionComponent={Transition}
      >
        <AppBar sx={{ position: "relative" }}>
          <Toolbar>
            <IconButton
              edge="start"
              color="inherit"
              onClick={onClose}
              aria-label="close"
            >
              <CloseIcon />
            </IconButton>
          </Toolbar>
        </AppBar>
        <Box margin={{ sm: 3, xs: 2 }}>
          <Stack spacing={1} direction="row" justifyContent={"flex-end"}>
            <Button
              variant="outlined"
              color="error"
              size="small"
              onClick={onClose}
              sx={{
                borderRadius: 10,
                textTransform: "none",
                ":hover": {
                  bgcolor: "error",
                  color: "error",
                  border: "error",
                },
              }}
            >
              Cancel
            </Button>
          </Stack>
        </Box>
      </Dialog>
    </div>
  );
};

export default FullScreenDialog;

当点击Cancel按钮时,同样的错误也会出现.即使从不同的组件单击Start按钮,也会出现相同的错误.

您认为MUI中有什么变化是导致此问题的原因吗?

推荐答案

这是在这个版本的material 用户界面中的一个倒退,这个问题已经在this pull request中解决了,应该会在future 一两天发布的下一个版本中包括在内.

Reactjs相关问答推荐

Reaction Native:在初始获取后,Reducer变为未定义

为什么我的标签在Redux API中不能正常工作?

从Microsoft Excel粘贴复制的单元格时,将Excel单元格格式(粗体、下划线、斜体)带入Reaction

下拉Tailwind CSS菜单与怪异beviour

如何使用皮金贴图在Reactjs中制作 map 上的点之间的线的动画?

为什么查询错误在处理后仍出现在控制台中?RTK查询+ React

试图从Amazon-Cogito-Identity-js模拟CogitoUser.authateUser,并将其获取为未定义的S

React-React中是否完全支持基于类的组件?

React-apexcharts 中的 Y 轴刻度不会动态更新符号

列表中的每个子项都应该有一个唯一的keyprops .在react 应用程序中

基于 React/NextJS Timer 的文本淡入/淡出不起作用

React + Redux:数据未正确传递给具有动态路由的组件

React Router v6 - 访问嵌套路由和处理手写 url 的正确方法

react-query、react-hook-form 和表单验证

Cypress - 在继续之前等待下一个按钮重新出现

如何在react 日历中自定义带有圆形边框的日期项?

在视图列表上react 本机无限循环的反弹动画?

React Hooks 表单在日志(log)中显示未定义的用户名

如何通过 Material Ui 设计将 Accordion 添加到您的 React 项目中?

Rtk 查询无效标签不使数据无效