Skip to content

Instantly share code, notes, and snippets.

@steniowagner
Last active March 10, 2022 15:25
Show Gist options
  • Save steniowagner/b3c9e1dccfea7bf61d585020232b3c97 to your computer and use it in GitHub Desktop.
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
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);
@lucasstarick
Copy link

Can you help me with this projet https://github.com/lucasstarick/offlinequeue ?
I'm using redux-saga, redux-persist and offline-queue...everything is working...but when i submit a request offline, close the app, open again and return with connection i have this problem. I think that can be a problem with store.

@ATXpert1
Copy link

Sorry if it's a stupid question, where is your reducer from the saga side? or you did something different

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment