0

在编译此代码时,我收到此错误SyntaxError: Unexpected token, expected ","。我希望你能帮我解决这个问题。在线错误(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;

谢谢

4

1 回答 1

5

你的电话createStore是错误的。它应该是参数列表,而不是对象:

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

正确的函数签名是:

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

在这里查看文档

于 2019-11-20T13:32:09.193 回答