通过 webpack 编译时收到此错误 意外令牌,预期","



编译此代码时,我会收到此错误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])

请参阅此处的文档

相关内容

  • 没有找到相关文章

最新更新