user3323307
user3323307

Reputation: 253

Problems with Material-UI components

I'm trying to use the http://www.material-ui.com/#/components/drawer (Docked Example) component from Material-UI with ReactJS.

I get error an error on the "=" in the following line:

handleToggle = () => this.setState({open: !this.state.open});

I get the same error on some other components as well. I'm using the latest version of Material-UI.

Same with this one: http://www.material-ui.com/#/components/table (Complex Example) on the following code:

handleToggle = (event, toggled) => {

Any ideas?

Thank you.

Upvotes: 0

Views: 1161

Answers (2)

user3323307
user3323307

Reputation: 253

Thanks for the input. I just had to add "stage-0" to my loaders and install "babel-preset-stage-0". Now everything works. Thanks again.

Upvotes: 0

Matt
Matt

Reputation: 3780

You'll either need to use an ES6 transpiler such as babel to convert your code to JS that current browsers can understand, or not use fat-arrow functions:

handleToggle() {
  this.setState({open: !this.state.open});
};

Upvotes: 1

Related Questions