Reputation: 143
I am working with redux toolkit and getting this error, here is my set up for store,
import { configureStore } from '@reduxjs/toolkit';
import { getDefaultMiddleware } from '@reduxjs/toolkit';
import counterReducer from './SlicesAndReducers';
import createSagaMiddleware from "redux-saga";
import rootSagaToolKit from './Sagas/SagaIndex'
import { applyMiddleware } from 'redux';
const sagaMiddleware = createSagaMiddleware();
const store = configureStore({
reducer: {
counter: counterReducer,
middleware: [...getDefaultMiddleware({ thunk: false }),sagaMiddleware],
}
});
sagaMiddleware.run(rootSagaToolKit);
export default store;
i already have check Stackoverflow , but haven't found any solution
Upvotes: 1
Views: 1463
Reputation: 118
This line shoule move out of reducer object.. middleware: [...getDefaultMiddleware({ thunk: false }),sagaMiddleware],
.. Check my sample below:
import { configureStore } from '@reduxjs/toolkit';
import { persistStore } from 'redux-persist';
import createSagaMiddleware from 'redux-saga';
import persistedReducer from './rootReducer';
import rootSaga from './rootSaga';
const sagaMiddleware = createSagaMiddleware();
export const store = configureStore({
reducer: persistedReducer,
middleware: getDefaultMiddleware =>
getDefaultMiddleware({
thunk: false,
immutableCheck: false,
serializableCheck: false
}).concat(sagaMiddleware),
devTools: process.env.NODE_ENV !== 'production'
});
export const persistor = persistStore(store);
sagaMiddleware.run(rootSaga);
Upvotes: 5