0

I'm using react and I'm trying to use the spread syntax. For some reason it doesn't work and it gives an error:

const { className, children, ...otherprops } = this.props;

Any idea what I'm doing wrong?

Patrick Roberts
  • 49,224
  • 10
  • 102
  • 153
Golan Kiviti
  • 3,895
  • 7
  • 38
  • 63

1 Answers1

4

You are getting Unexpected token because you are missing one babel preset, stage-0

With stage-0, it works

Without stage-0, it doesn't work

In order to add it, you have to

1º Install it

npm install --save-dev babel-preset-stage-0

2º Add it to .babelrc

{
  "presets": ["react","es2015","stage-0"]
}
QoP
  • 27,388
  • 16
  • 74
  • 74
  • Have the same issue.I tried both the steps and still its showing the same error. I am using CoreUi react theme. Also tried state 2 still not fixed – CyberAbhay Aug 16 '18 at 12:41