我有一个组件View
:
import React from 'react';
import { AppBar, Toolbar } from 'material-ui';
import { Typography } from 'material-ui';
import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles';
import {lightBlue} from 'material-ui/colors';
const theme = createMuiTheme({
palette: {
primary: {main:lightBlue['A700']}
},
});
const View = (props) => (
<MuiThemeProvider theme={theme}>
<AppBar position="static">
<Toolbar>
<Typography variant="title">
{props.title}
</Typography>
</Toolbar>
</AppBar>
</MuiThemeProvider>
);
export default View;
如您所见,该组件使用自己的MuiThemeProvider
。 View组件不是整个应用程序的根组件,它是App
根组件的子组件,App
组件包含多个组件。
我的问题是,将MuiThemeProvider
分配给非View
之类的根组件是错误的吗?