Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MetaThemeColor extends React.Component {
- render() {
- const {color} = this.props;
- if (window && window.document) {
- const metaThemeColor = window.document.createElement('meta');
- const nameAttribute = window.document.createAttribute('name');
- nameAttribute.value = 'theme-color';
- const contentAttribute = window.document.createAttribute('content');
- contentAttribute.value = color;
- metaThemeColor.setAttributeNode(nameAttribute);
- metaThemeColor.setAttributeNode(contentAttribute);
- window.document.getElementsByTagName('head')[0].appendChild(metaThemeColor);
- }
- return null;
- }
- }
- //в render()-методе App:
- render() {
- const {localeStore} = this.props;
- const pickersLocale = muiPickersLocaleMap[localeStore.currentLocale] || enLocale;
- return <div style={{
- flexGrow: 1
- }}>
- <MuiThemeProvider theme={theme}>
- <MuiPickersUtilsProvider utils={DateFnsUtils} locale={pickersLocale}>
- <MetaThemeColor color={theme.palette.primary.main}/>
- <MobxRouter/>
- </MuiPickersUtilsProvider>
- </MuiThemeProvider>
- </div>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement