【发布时间】:2020-07-20 16:40:54
【问题描述】:
我是 react 和 typescript 的新手。 我正在尝试在全局主题上扩展调色板。
在我的 themeContainer.tsx 中
import { ThemeOptions } from '@material-ui/core/styles/createMuiTheme';
declare module '@material-ui/core/styles/createPalette' {
// allow configuration using `createMuiTheme`
interface Palette {
accent: PaletteColor
}
interface PaletteOptions {
accent: PaletteColorOptions,
tertiary: PaletteColorOptions
}
};
const ThemeContainer: React.FunctionComponent<Props> = (props, themeOptions: ThemeOptions) => {
const { children } = props;
const theme = useMemo(() => {
const nextTheme = createMuiTheme({
...themeOptions,
palette: {
accent: {
main: '#ff0000'
},
}
});
return nextTheme;
});
return <ThemeProvider theme={theme}>{children}</ThemeProvider>;
};
export default ThemeContainer;
但是在我的组件上,出现了错误。
此调用没有过载。
提前谢谢你。
【问题讨论】:
标签: typescript material-ui next.js