我的猜測是,你沒做這個重大更改任何東西:
截至目前,您需要提供上下文主題,請參閱:http://www.material-ui.com/#/customization/themes
所以材料的UI如果你沒有指定主題,現在似乎打破了。你可以將你的整個應用程序包裝在MuiThemeProvider中,然後重新開始工作。
你會需要像:
...
import MuiThemeProvider from "material-ui/styles/MuiThemeProvider"
import getMuiTheme from "material-ui/styles/getMuiTheme"
// import the colors wanted to customize your theme here, if you want to
import { orange500 } from "material-ui/styles/colors"
...
// customize your theme here
const muiTheme = getMuiTheme({
palette: {
accent1Color: orange500
}
})
...
class MyApp extends Component {
render() {
return (
<MuiThemeProvider muiTheme={muiTheme}>
<div>
<Header />
<Body />
<Footer />
</div>
</MuiThemeProvider>
)
}
}
有一點需要注意的是,MuiThemeProvider預計只有一個孩子,所以沒有避免封裝格;當然,如果你想讓事情變得更清潔,你可以創建另一個AppContainer組件,但你明白了。
感謝您輸入約翰尼,我已經這樣做,但即使如此,仍然得到同樣的問題。 而我的假設是,所有的子組件都不需要用'MuiThemeProvider'來包裝,因爲它應該從父類繼承上下文。 –
您正在使用哪些組件?我在使用下拉菜單時看到這個問題:https://github.com/callemall/material-ui/issues/3756如果你也使用它,並且我知道你有很多代碼,但是你可能可能嘗試用其他東西替換該組件?確認或揭發這個錯誤與這個具體事情有關。 –
我確實看到了這個問題,並且您可以看到我的+1以及:) 但這是相當古老的,似乎不會與我們的相關。 這是所有頁面上接受第一個。 –