Error when trying material-ui SelectField component

2.7k views Asked by At

I'm trying out material-ui right now. I am new to react.js and material-ui and somehow manage to go through some stuff, but cannot use the SelectField. Whenever I use the SelectField component, I get a

Uncaught TypeError: Cannot read property 'toUpperCase' of undefinederror.

I have followed how it is written in:material-ui.com

This is my selectField.jsx file:

var React = require('react');
var mui = require('material-ui');
var SelectField = mui.SelectField;
var ThemeManager = new mui.Styles.ThemeManager();
var Colors = mui.Styles.Colors;
var StyleResizable = mui.Mixins.StyleResizable;

var menuItems = [
{ payload: '1', text: 'Never' },
{ payload: '2', text: 'Every Night' },
{ payload: '3', text: 'Weeknights' },
{ payload: '4', text: 'Weekends' },
{ payload: '5', text: 'Weekly' },
];

var Main = React.createClass({

  getInitialState: function() {
    return { selectValue: undefined};
  },

  childContextTypes: {
    muiTheme: React.PropTypes.object
  },

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

  render: function() {
    return (
      <SelectField
      value={this.state.selectValue}
      onChange={this._handleSelectValueChange}
      floatingLabelText="Select Field"
      menuItems={menuItems} />
    );
  },

  _handleSelectValueChange: function(e) {
    this.setState({
      selectValue: e.target.value
    });
  }
});

module.exports = Main;

Any ideas why it outputs an error? Other material-ui components works fine.

EDIT:

This is my parent component in app.jsx file:

(function () {
  var React = require('react');
  var injectTapEventPlugin = require('react-tap-event-plugin');
  var Main = require('./components/selectField.jsx'); 

  window.React = React;

  injectTapEventPlugin();

  React.render(<Main />, document.body);

})();
0

There are 0 answers