Я пытаюсь запустить несколько функций стрелок в моем коде реагирования, но, несмотря на добавление загрузчиков babel для построения кода в читаемом формате, я получаю сообщение об ошибке в части =
моих функций стрелок.
export default class CommentForm extends React.Component {
constructor(props){
super(props);
...
this.state = {
value: '',
flash: '',
suggestions: [],
};
this.onChange = this.onChange.bind(this);
this.focus = this.focus.bind(this);
}
...
onChange = (editorState) => {
this.setState({
suggestions: ['test']
});
}
...
}
Ошибка:
ERROR in ./public/components/app/activity-feed/feed/VerticalTimeline/CommentComponents/CommentForm.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (150:13)
webpack.config.js:
module.exports = {
mode: 'development',
entry: "./public/index.js",
output: {
path: __dirname + "/dist",
filename: "bundle.js"
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader"
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
}
]
},
};
package.json:
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
....
}