【发布时间】:2017-05-26 12:59:19
【问题描述】:
我收到了这个警告:
Material-UI: userAgent should be supplied in the muiTheme
context for server-side rendering
使用以下服务器端渲染设置,我做错了什么:
match({routes: R(), location}, (error, redirectLocation, renderProps) => {
if (error) {
console.error("error: "+ error)
} else if (redirectLocation) {
console.error("redirect to " + redirectLocation)
} else if (renderProps) {
const theme = getMuiTheme({userAgent: "all"})
page = ReactDOMServer.renderToStaticMarkup(
<MuiThemeProvider muiTheme={theme}>
<Provider store={store}>
<RouterContext {...renderProps} />
</Provider>
</MuiThemeProvider>
)
} else {
console.error("location nof found: '"+ location +"'")
}
})
【问题讨论】:
-
我也有同样的问题。从 material-ui 文档来看,“所有”用户代理似乎应该可以工作,但它没有。此外,请仔细检查服务器和客户端的环境是否与其文档中描述的相同。 material-ui.com/#/get-started/server-rendering
标签: reactjs react-router material-ui