Last active
March 10, 2022 15:25
-
-
Save steniowagner/b3c9e1dccfea7bf61d585020232b3c97 to your computer and use it in GitHub Desktop.
Basic setup of Redux-Store + Redux-Persist + Redux-Saga. You can find a snippet that use this configuration here: https://gist.github.com/steniowagner/e778fcae0d8eb77b82da983fb46c2826
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore, applyMiddleware, compose } from 'redux'; | |
import createSagaMiddleware from 'redux-saga'; | |
import { persistStore, persistCombineReducers } from 'redux-persist'; | |
import storage from 'redux-persist/es/storage'; | |
import rootSaga from './sagas'; | |
/* Reducers */ | |
import { reducer as coachProfile } from './ducks/coach-profile'; | |
import { reducer as player } from './ducks/player'; | |
import { reducer as fileManager } from './ducks/file-manager'; | |
const reducers = { | |
coachProfile, | |
player, | |
fileManager, | |
}; | |
/* Redux-Persist */ | |
const rootReducer = persistCombineReducers({ | |
key: 'root', | |
storage, | |
}, reducers); | |
const middlewares = []; | |
const enhancers = []; | |
/* Saga */ | |
const sagaMonitor = __DEV__ ? console.tron.createSagaMonitor() : null; | |
const sagaMiddleware = createSagaMiddleware({ sagaMonitor }); | |
middlewares.push(sagaMiddleware); | |
enhancers.push(applyMiddleware(...middlewares)); | |
/* Create Store */ | |
const createAppropriateStore = __DEV__ ? console.tron.createStore : createStore; | |
export const store = createAppropriateStore( | |
rootReducer, | |
compose(...enhancers), | |
); | |
/* Redux-Persist + Store */ | |
export const persistor = persistStore(store); | |
/* Run saga */ | |
sagaMiddleware.run(rootSaga); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry if it's a stupid question, where is your reducer from the saga side? or you did something different