Reputation: 2463
ERROR in ./src/js/HomeView.js
Module build failed: SyntaxError: Unexpected token (122:19)
120 | }
121 |
> 122 | handleDrawerOpen = () => {
| ^
123 | this.setState({ open: true });
124 | };
125 |
Got the above error when trying to compile react component using webpack. Does anyone know what is the missing plugin here?
Upvotes: 0
Views: 116
Reputation: 1139
You'll probably need to install preset-stage-2.
This babel plugin allows you to use ES6+ features such as static
s, property initializers
, and even dynamic import support.
You could actually just install transform-class-properties for this particular case, but I usually prefer to install a babel plugin with stage-x because I find it comfortable to use multiple ES6+ features with a single install.
It might also be useful to future readers that this particular Babel plugin is already properly set up for you if you use create-react-app, as you can check here.
Upvotes: 1
Reputation: 2832
Difficult to guess from the code you have pasted above.
My guess is change it to
handleDrawerOpen() {
this.setState({ open: true });
}
Upvotes: 0