I'm trying to use the drawer of the ui material, however it 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 task of browserify and babel in 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));
});