通过 webpack Unexpected token, expected "," 编译时出现这个错误

Getting this error on compiling through webpack Unexpected token, expected ","

在编译此代码时,我收到此错误 SyntaxError: 意外标记,应为 ","。我希望你能帮我解决这个问题。在线错误 (13:39)

import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import rootReducers from './reducers';

const initialState = {};

const middleware = [thunk];

const store = createStore({
    rootReducers,
    initialState,
    composeWithDevTools(applyMiddleware(...middleware))
});

export default store;

谢谢

您对 createStore 的调用是错误的。它应该是一个参数列表,而不是一个对象:

const store = createStore(rootReducers, initialState, composeWithDevTools(applyMiddleware(...middleware)));

正确的函数签名是:

 createStore(reducer, [preloadedState], [enhancer])

查看文档 here