I use webpack to build the project. Configuration here:

'use strict'; const NODE_ENV = process.env.NODE_ENV || "development"; const webpack = require('webpack'); module.exports = { context: __dirname + '/src', entry: { main: "./main", common: "./common" }, output: { path: __dirname + (NODE_ENV == "development" ? "/www/js-dev/" : "/www/js/"), filename: "[name].js" }, module: { loaders: [ { test: /\.(js|jsx)?$/, exclude: /node_modules/, loader: 'babel', query: { presets: ["es2015", "react"] } } ] }, watch: NODE_ENV == "development", devtool: NODE_ENV == "development" ? "source-map" : null, plugins: [ new webpack.NoErrorsPlugin(), new webpack.DefinePlugin({ NODE_ENV: JSON.stringify(NODE_ENV), LANG: JSON.stringify("en") }), new webpack.optimize.CommonsChunkPlugin({ name: "common", minChunks: 2 }) ], resolve: { modulesDirectories: ['node_modules'], extensions: ['', '.js'] } }; if (NODE_ENV == "production") { module.exports.plugins.push( new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false, drop_console: true } }) ); } 

In this case, the error causes the following syntax:

 class Footer extends React.Component { //... handleChange = (event, index, value) => this.setState({value}); //... } 

What to do so that everything is generated normally?

This error code does not cause, but does not work:

 class Footer extends React.Component { //... handleChange (event, index, value) { this.setState({value}); } //... } 
  • one
    Well, this is the syntax error in the second code that you have. And where did you get that does not work last? As far as I can see, it works. You must have this.state = {value: 'someValue'}; . And how do you try to call handleChange ? - Vasily Barbashev
  • The code in which, as you write, there is a syntax error is taken from here: material-ui.com/#/components/toolbar The last option really works. I don't know why I thought not ( - Razzwan
  • Hm, strangely enough the parser does not swear on the second code, but it also does not work. But the first time I meet this writing. Perhaps you need some kind of plugin or a specific version of babel for its work. I use the stage-1 + plugin for decorators. But earlier it caused a mistake to me, now it isn’t, but it doesn’t work either)) - Vasily Barbashev

0