abr*_*raj 2 reactjs material-ui
在以下代码中,我在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"));
Run Code Online (Sandbox Code Playgroud)
我收到以下警告:
Warning: Material-UI: you are using the deprecated typography variants that will be removed in the next major release.
我没有使用任何排版(更不用说任何不推荐使用的排版变体)
为什么会收到此警告?有人可以解释一下。
在codeandbox上的完整演示:https ://codesandbox.io/s/r5v9pjxnq4
最少的复制代码:https://codesandbox.io/s/p9628o7wlj
(结果发现使用createMuiTheme也会给出警告!)
我只是添加我的index.html:
<script>window.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true</script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2503 次 |
| 最近记录: |