在以下代码中,我在 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/p9628o7wlj
(结果只是使用createMuiTheme
也会给出警告!)