Reputation: 571
Does anyone know how to enable support for properties of a class in the latest version BabelJS?
import React from 'react';
import {Component} from 'react';
export default class Button extends Component {
constructor(){
super();
}
myProp = {}; // ERROR: /path/to/file/Button.jsx: Unexpected token (9:11)
render(){
return <div></div>;
}
}
Upvotes: 0
Views: 373
Reputation: 1074979
With Babel 6, you use the syntax-class-properties
plugin, by installing it:
npm install babel-plugin-syntax-class-properties
and adding it to your .babelrc
:
{
"plugins": ["syntax-class-properties"]
}
Upvotes: 2