问题
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.
回答1:
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});
};
回答2:
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.
来源:https://stackoverflow.com/questions/37544124/problems-with-material-ui-components