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?
You are getting Unexpected token
because you are missing one babel preset, stage-0
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"]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.