js和我想在SSR中使用Material UI。我进行了here这样的设置,但出现了错误Cannot read property 'button' of undefined
theme.ts
import { createMuiTheme, ThemeOptions } from '@material-ui/core/styles';
const theme = (options: ThemeOptions) => {
return createMuiTheme({
palette: {
primary: {
main: '#b5ddd1'
},
secondary: {
main: '#b2d9ea'
},
},
...options,
})
}
Next.js说我在_document.tsx
中有问题
import { ServerStyleSheets, ThemeProvider } from '@material-ui/core/styles'
import theme from '../src/common/theme'
...
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App: any) => (props: any) => sheet.collectStyles(sheets.collect(<ThemeProvider theme={theme}><App {...props} /></ThemeProvider>)),
})
我不确定我在做错什么吗?
感谢您的帮助! ??