Search code examples
reactjsreduxredux-sagaredux-thunk

Using Redux-Saga in New Redux template react app


The new redux has a template built in for store and all the necessary thing to start a react redux app but it is using redux-thunk under the hood to make async calls. It it not possible to replace this with redux-saga instead of thunk.


Solution

  • Redux Toolkit allows you to customize the list of middleware you're using using the middleware option of configureStore, same as if you're creating a Redux store with the base createStore API.

    You can completely replace the default list of pre-defined middleware by providing your own middleware array, or call getDefaultMiddleware() and add your own middleware to the array and use that.

    So, my advice would be to do:

    const store = configureStore({
      reducer: rootReducer,
      middleware: getDefaultMiddleware().concat(sagaMiddleware)
    })