未捕获TypeError:_materialUi.Styles.ThemeManager与es6一起使用material-ui时不是函数

时间:2015-11-15 15:36:12

标签: javascript ecmascript-6 material-ui

我使用material-ui构建我的网络应用程序。但是我收到了错误Uncaught TypeError: _materialUi.Styles.ThemeManager is not a function。我还搜索了github并发现了这个问题ThemeManager is not a function error,但它没有用。

我的依赖项:

"material-ui": "^0.13.0",
"react": "^0.14.0"
"react-dom":"^0.14.0"

这是我的代码:

import React from 'react';
import mui, { RaisedButton, Dialog, Styles } from 'material-ui';

const ThemeManager = new Styles.ThemeManager();
const Colors = Styles.Colors;

class Main extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            muiTheme: ThemeManager.getCurrentTheme()
        }
    }

    getChildContext() {
        return { muiTheme: this.state.muiTheme };
    }

    componentWillMount() {
        let newMuiTheme = ThemeManager.modifyRawThemePalette(this.state.muiTheme, {
            accent1Color: Colors.deepOrange500
        });

        this.setState({muiTheme: newMuiTheme});
    }


    _handleTouchTap() {
        this.refs.superSecretPasswordDialog.show();
    }

    render() {
        let containerStyle = {
            textAlign: 'center',
            paddingTop: '200px',
        };

        let standardActions = [
            { text: 'Okay' },
        ];

        return (
            <div style={containerStyle}>
                <Dialog
                    title="Super Secret Password"
                    actions={standardActions}
                    ref="superSecretPasswordDialog">
                    1-2-3-4-5
                    </Dialog>

                <h1>material-ui</h1>
                <h2>example project</h2>
                <RaisedButton label="Super Secret Password" primary={true} onTouchTap={this._handleTouchTap} />

            </div>
        );
    }
}

Main.childContextTypes = {
    muiTheme: React.PropTypes.object
}

export default Main;

0 个答案:

没有答案