在 Material-UI 中使用自定义主题时已弃用版式警告

2024-03-16

在下面的代码中,我在 Material-UI 中使用了自定义主题:

import React from "react";
import ReactDOM from "react-dom";
import { MuiThemeProvider, createMuiTheme } from "@material-ui/core/styles";
import Button from "@material-ui/core/Button";
import { purple, green } from "@material-ui/core/colors";

const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green
  }
});

function App() {
  return (
    <MuiThemeProvider theme={theme}>
      <Button color="primary">Button1</Button>
      <Button color="secondary">Button2</Button>
    </MuiThemeProvider>
  );
}

ReactDOM.render(<App />, document.getElementById("root"));

我收到以下警告: Warning: Material-UI: you are using the deprecated typography variants that will be removed in the next major release.

我没有使用任何排版(更不用说任何已弃用的排版变体)

为什么我会收到此警告?有人可以解释一下吗?
完整演示请参见codesandbox:https://codesandbox.io/s/r5v9pjxnq4 https://codesandbox.io/s/r5v9pjxnq4

最小重现代码:https://codesandbox.io/s/p9628o7wlj https://codesandbox.io/s/p9628o7wlj
(结果只是使用createMuiTheme还给出警告!)


我只是添加我的index.html:

<script>window.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Material-UI 中使用自定义主题时已弃用版式警告 的相关文章

随机推荐