0

The exact error message is

Module parse failed: /www/devreact/node_modules/jsx-loader/index.js!/www/devreact/app/dashboard.js Line 11: Unexpected token ( You may need an appropriate loader to handle this file type.

Webpack is failing on the following code below. '

var Add = React.createClass({
  render () {
    var sum = this.props.x + this.props.y;
    return React.DOM.span({}, sum);
  }
});

Here are the loaders being loaded in my webpack.config.js file.

  module:{
    loaders:[ /*Loaders like helprs Good for transcompiling ES6 */
      {test:/\.js$/,loader:'jsx-loader'} /*Test whenever you hit a javascript file use jsx-loader When using require module */
      ,{test:/\.json$/,loader:'json-loader'}
    ]
  },

1 Answer 1

1

render needs to be a function:

var Add = React.createClass({
  render: function () {
    var sum = this.props.x + this.props.y;
    return React.DOM.span({}, sum);
  }
});

Otherwise, you will have a syntax error defining the object literal inside the creatClass.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.