reactjsreduxreact-reduxredux-thunkredux-devtools-extension

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


On compiling this code, I m getting this error SyntaxError: Unexpected token, expected ",". I hope you could help me with this. Error on line(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;

Thank you


Solution

  • Your call to createStore is wrong. It should be a list of paramaters, not an object:

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

    The correct function signature is:

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

    see the docs here