I cannot use material-ui components after update to material-ui@0.15.0-beta.1

后端 未结 3 1603
青春惊慌失措
青春惊慌失措 2021-02-07 01:58

I got this message in my console:

Failed Context Types: Required context muiTheme was not specified in AppBar

AppB

3条回答
  •  你的背包
    2021-02-07 02:38

    With material-ui@0.15.0.beta-1 a few things were changed.

    You can have a look on the link below for more details. https://github.com/callemall/material-ui/blob/master/CHANGELOG.md

    Therefore with those changes your code becomes:

        import React from 'react';
        import AppBar from 'material-ui/AppBar';
        import baseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
        import getMuiTheme from 'material-ui/styles/getMuiTheme';
    
            export class MyComponent extends React.Component {
    
                getChildContext() {
                    return { muiTheme: getMuiTheme(baseTheme) };
                }
    
                render() {
                    return (
                        
    ); } } MyComponent.childContextTypes = { muiTheme: React.PropTypes.object.isRequired, };

提交回复
热议问题