2
I am trying to use the Drawer of the ui material, but is returning the following error when Gulp will process it:
Unexpected token (15:17) handleToggle = () => this.setState({open: ! this.state.open})
The error points to the "=" after "hanbleToggle"
The code is as follows::
import React from 'React'; import Drawer from 'material-ui/Drawer'; import Menuitem from 'material-ui/Menuitem'; import Raisedbutton from 'material-ui/Raisedbutton';
export default class Drawersimpleexample extends React.Component {
constructor(props) { super(props); this.state = {open: false}; } handleToggle = () => this.setState({open: !this.state.open}); render() { return ( <div> <RaisedButton label="Toggle Drawer" onTouchTap={this.handleToggle} /> <Drawer open={this.state.open}> <MenuItem>Menu Item</MenuItem> <MenuItem>Menu Item 2</MenuItem> </Drawer> </div> ); } }
My Browserify and Babel task at Gulp:
Gulp.task('Browserify', Function() {
browserify({ entries: './app/app.js', extensions: config.extensions, debug: config.debug }) .transform(babelify,{presets: ["es2015", "react"]}) .bundle() .pipe(source(config.bundleConfigs.outputName)) .pipe(gulp.dest(config.bundleConfigs.dest));
});
Well, the problem was that I needed to guess Babel Stage-0. I was able to solve.
– Juliano Bailão