1

I have done hours of debugging and I am unable to find the solution.

import { combineReducers, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { configureStore } from '@redux.js/toolkit';
import { composeWithDevTools } from 'redux-devtools-extension';

let reducer = combineReducers({
  // contains all reducers
});

// here all our data will lie
const initialState = {};

const middleware = [thunk];

const store = configureStore(
  reducer,
  initialState,
  composeWithDevTools(applyMiddleware(...middleware))
);

export default store;

Error:

enter image description here

I just want a todo list to be displayed on browser, which I have written in my App.js.

Drew Reese
  • 165,259
  • 14
  • 153
  • 181

2 Answers2

1

The configureStore utility takes a single argument object with properties reducer, middleware, devTools, preloadedState, and enhancers.

import { configureStore } from '@reduxjs/toolkit';
import { combineReducers } from 'redux';

const rootReducer = combineReducers({
  // contains all reducer functions
});

const initialState = {};

const store = configureStore({ // <-- single object argument
  reducer: rootReducer,
  preloadedState: initialState,
});

export default store;

Note that I didn't include the Thunk middleware since Redux Toolkit comes with the Thunk middleware by default, and I didn't include any regarding devTool since these are also enabled by default.

Drew Reese
  • 165,259
  • 14
  • 153
  • 181
0

Try:

const store=configureStore(
    {
        reducer,
        initialState,
        composeWithDevTools( ... )
    }
)

export default store;

Help for posting code in Stack Overflow:

  1. How do I format my posts using Markdown or HTML?
  2. Markdown help
kofeigen
  • 1,331
  • 4
  • 8