How to use the redux-persist.persistCombineReducers function in redux-persist

To help you get started, we’ve selected a few redux-persist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github victorkvarghese / react-native-messenger / src / store / configureStore.js View on Github external
const config = {
    key: 'root',
    storage,
    blacklist: ['loadingReducer'],
    debug: true //to get useful logging
};

const middleware = [];
const sagaMiddleware = createSagaMiddleware();
middleware.push(sagaMiddleware);

if (__DEV__) {
    middleware.push(createLogger());
}

const reducers = persistCombineReducers(config, rootReducers);

const enhancers = [applyMiddleware(...middleware)];
// const initialState = {};
const persistConfig = { enhancers };
let store = createStore(reducers, undefined, compose(...enhancers));
const persistor = persistStore(store, persistConfig, () => {
    // console.log('Test', store.getState());
});
const configureStore = () => {
    return { persistor, store };
};

sagaMiddleware.run(sagas);

export default configureStore;
github rock-solid / pwa-theme-woocommerce / src / configureStore.js View on Github external
key: 'root',
  storage,
  blacklist: [
    'navbar',
    'search',
    'toastr',
    'categories',
    'products',
    'reviews',
    'variations',
    'cart',
  ],
  // debug: true,
};

const rootReducer = persistCombineReducers(rootPersistConfig, {
  categories: persistReducer(
    {
      key: 'categories',
      storage,
      blacklist: config.OFFLINE ? ['isFetching', 'hasMore'] : ['isFetching', 'hasMore', 'items'],
    },
    categories,
  ),
  products: persistReducer(
    {
      key: 'products',
      storage,
      blacklist: config.OFFLINE ? ['isFetching', 'hasMore'] : ['isFetching', 'hasMore', 'items'],
    },
    products,
  ),
github kyaroru / ReactNavTab / src / store / configureStore.js View on Github external
import storage from 'redux-persist/lib/storage';
import createSagaMiddleware from 'redux-saga';
import reducers from 'reducers';
import sagas from 'sagas';

let middlewares;
let store;
const sagaMiddleware = createSagaMiddleware();

const config = {
  key: 'root',
  storage,
  whitelist: ['PERSIST'],
};

const reducer = persistCombineReducers(config, reducers);

/* global __DEV__ */
if (__DEV__) {
  const excludedActions = [];
  const logger = createLogger({
    collapsed: true,
    predicate: (getState, action) => excludedActions.indexOf(action.type) < 0,
  });
  middlewares = applyMiddleware(sagaMiddleware, logger);
} else {
  middlewares = applyMiddleware(sagaMiddleware);
}

export const getStore = () => store;

const configureStore = () => {
github punksta / Cat-or-dog / src / configureStore.js View on Github external
export default navigationService => {
	const persistConfig = {
		key: "rootReducer",
		storage,
		whitelist: ["gameHistory", "levels", "settings"],
		version: 1
	};

	const persistedReducer = persistCombineReducers(persistConfig, {
		gameHistory,
		levels,
		settings
	});

	const dependencies = {
		navigationService
	};

	const epicMiddleware = createEpicMiddleware({dependencies});
	const middlewares = [epicMiddleware];
	if (isDebug()) {
		middlewares.push(require("redux-logger").default);
	}

	const store = createStore(persistedReducer, applyMiddleware(...middlewares));
github imshubhamsingh / FarmerChain / src / Reducers / index.js View on Github external
import CartFarmReducer from "./CartFarmReducer";
import TransactionReducer from "./TransactionReducer";
import FarmerBankReducer from "./FarmerBankReducer";
import PoolReducer from "./PoolReducer";
import HeaderTextReducer from "./HeaderTextReducer";
import Web3Reducer from "./Web3Reducer";

import { persistCombineReducers } from 'redux-persist'
import storage from 'redux-persist/es/storage'

const config = {
    key: 'root',
    storage,
}

export const reducer = persistCombineReducers(config, {
    user: UserReducer,
    pools: PoolFarmReducer,
    products: CartFarmReducer,
    transactions: TransactionReducer,
    loans: FarmerBankReducer,
    admin: PoolReducer,
    header: HeaderTextReducer,
    web3: Web3Reducer
})
github foxfolio / foxfolio-desktop / app / modules / index.ts View on Github external
import { History } from './history.types';
import prices from './prices';
import { Prices } from './prices.types';
import settings from './settings';
import { SettingsType } from './settings.types';
import ticker from './ticker';
import { Ticker } from './ticker.types';
import timers from './timer';
import { Timers } from './timer.types';
import trades from './trades';
import { TradesMap } from './trades.types';
import wallets from './wallets';
import { Wallets } from './wallets.types';

const config = configureReduxPersist();
export const rootReducer = persistCombineReducers(config, {
  coinlist,
  exchanges,
  form,
  history,
  router,
  prices,
  settings,
  ticker,
  timers,
  trades,
  wallets,
} as any);

export interface GlobalState {
  coinlist: Coinlist;
  exchanges: Exchanges;
github HiDeoo / YaTA / src / store / index.ts View on Github external
import * as storage from 'localforage'
import { applyMiddleware, compose, createStore, Middleware, Store } from 'redux'
import { createMigrate, persistCombineReducers, Persistor, persistStore } from 'redux-persist'

import migrations from 'store/migrations'
import reducers, { ApplicationState } from 'store/reducers'

/**
 * Combined & persisted reducers.
 */
const persistedReducers = persistCombineReducers(
  {
    key: 'YaTA:store',
    migrate: createMigrate(migrations as any, { debug: false }),
    storage,
    version: 41,
    whitelist: ['settings', 'user', 'notes'],
  },
  reducers
)

/**
 * Creates and configures the Redux Store.
 * @return The Redux store configuration containing the actual store and the persistor.
 */
export default function configureStore(): StoreConfiguration {
  const middlewares: Middleware[] = []
github dgraph-io / ratel / client / src / reducers / index.js View on Github external
export default function makeRootReducer(config) {
    return persistCombineReducers(config, {
        frames,
        connection,
        query,
        ui,
        url,
    });
}
github cozy / cozy-bar / src / lib / store / mobile.js View on Github external
import { createStore, applyMiddleware } from 'redux'
import thunkMiddleware from 'redux-thunk'
import { persistStore, persistCombineReducers } from 'redux-persist'
import { reducers } from '../reducers'
import localForage from 'localforage'

const config = {
  key: 'cozy-bar',
  storage: localForage,
  whitelist: ['locale', 'apps']
}

const reducer = persistCombineReducers(config, { ...reducers })

const createReduxStore = () => {
  let store = createStore(
    reducer,
    applyMiddleware(thunkMiddleware)
  )
  persistStore(store)

  return store
}

export default createReduxStore
github zxj963577494 / OverWatchTeams / src / store / configureStore.dev.js View on Github external
import { persistStore, persistCombineReducers } from 'redux-persist'
import storage from 'redux-persist/es/storage'
import CreateSagaMiddleware, { END } from 'redux-saga'
import { routerReducer, routerMiddleware } from 'react-router-redux'
import createHistory from 'history/createBrowserHistory'
import { createLogger } from 'redux-logger'
//import DevTools from '../containers/DevTools/DevTools'
import reducers from '../reducers'

const config = {
  key: 'root',
  storage,
  debug: true
}

const reducer = persistCombineReducers(config, {
  ...reducers,
  router: routerReducer
})

export default function configureStore(initialState) {
  const sagaMiddleware = CreateSagaMiddleware()
  const history = createHistory()
  const routeMiddleware = routerMiddleware(history)
  const loggerMiddleware = createLogger()
  const middlewares = [routeMiddleware, sagaMiddleware, loggerMiddleware]
  const enhancers = compose(
    applyMiddleware(...middlewares),
    window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
    //DevTools.instrument(),
  )
  const store = createStore(reducer, initialState, enhancers)