this is my babelrc config
{
"presets": [
"react",
"es2015"
],
"plugins": [
"transform-es2015-arrow-functions"
]
}
and my component code:
import React from 'react';
import { render } from 'react-dom';
class App extends React.Component {
constructor(props) {
super(props);
}
_handleClick = (e) => {
}
render() {
return (
<div>App</div>
);
}
}
render(
<App />,
document.getElementById('app')
);
but it throw an error when webpack or babel main.js -p out.js
SyntaxError: main.js: Unexpected token (9:17)
7 | super(props);
8 | }
> 9 | _handleClick = (e) => {
| ^
10 |
11 | }
12 | render() {
You need to enable class properties. (i.e. use the appropriate plugin for that under Babel 6)
@mathieumg thanks your answer. can you give some demo code like my babelrc?
{
"presets": [
"react",
"stage-1"
]
}
solved
Most helpful comment
solved