Answer the question
In order to leave comments, you need to log in
How to add redux saga to redux toolkit?
Please tell me if I'm doing it right?
import { configureStore } from '@reduxjs/toolkit'
import { rootReducer } from './rootReducer'
import createSagaMiddleware from 'redux-saga'
const sagaMiddleware = createSagaMiddleware()
export const store = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({
thunk: false,
serializableCheck: false,
}).concat(sagaMiddleware),
})
Answer the question
In order to leave comments, you need to log in
Works? So right. Does not work? What doesn't work?
There must be a .run() somewhere else, if my memory serves me.
and why thunk: false? like because thunk is under the hood of the toolkit?
I did this:
export const setupStore = () => {
const sagaMiddleware = createSagaMiddleware();
const store = configureStore({
reducer: rootReducer,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({ thunk: false }).concat(sagaMiddleware),
});
sagaMiddleware.run(rootWatcher);
return store;
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question