无法读取未定义的 'component':将 material-ui 与 browserify 一起使用

Cannot read 'component' of undefined: Using material-ui with browserify

我正在使用 browserify 来管理我的依赖项,正如 material-ui 安装文档中所建议的那样。当我尝试 运行 我的代码时,控制台给我这条消息:

Uncaught TypeError: Cannot read property 'component' of undefined,追溯到bundle.js:6769

在我的bundle.js文件中,第6769行是这个函数的return语句:

    getThemeButton: function getThemeButton() {
        return this.context.muiTheme.component.button;
    },

我在这里错过了什么?我对 material-ui 和我正在使用的 material-ui 组件都有 require 语句。

我的 index.js 文件的顶部如下所示:

    var React = require('react');
    var injectTapEventPlugin = require('react-tap-event-plugin');
    var mui = require('material-ui');
    var RaisedButton = mui.RaisedButton;

    injectTapEventPlugin();

找到隐藏在docs中的答案!

显然这是 material-ui 的 required 部分(我不知道他们为什么不将其作为设置的一部分) ,但我需要在渲染的 类:

中包含此代码段
childContextTypes: {
    muiTheme: React.PropTypes.object
},

getChildContext: function() {
    return {
      muiTheme: ThemeManager.getCurrentTheme()
    };
},