How to use the redux-persist.persistReducer 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 unreg / loreader / src / store.js View on Github external
import { createStore } from 'redux';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import autoMergeLevel1 from 'redux-persist/lib/stateReconciler/autoMergeLevel1';

import reducers from './reducers';


const persistConfig = {
  key: 'root',
  storage,
  stateReconciler: autoMergeLevel1
}

const persistedReducer = persistReducer(persistConfig, reducers)

export const store = createStore(persistedReducer);
// export const persistor = persistStore(store, null, () => {console.log('Rehydrated')});
export const persistor = persistStore(store);
github MacKentoch / react-redux-nextjs-bootstrap-pwa-starter / redux / store / configureStore.dev.js View on Github external
});
// #endregion

// #region createStore : enhancer
const enhancer = composeWithDevTools(
  applyMiddleware(thunkMiddleware, fetchMiddleware, loggerMiddleware),
);
// #endregion

// #region persisted reducer
const persistConfig = {
  key: 'root',
  storage,
};

const persistedReducer = persistReducer(persistConfig, reducer);
// #endregion

// #region store initialization
export default function configureStore(initialState) {
  const store = createStore(persistedReducer, initialState, enhancer);

  // we won't need PersistGate since server rendered with nextJS:
  // const persistor = persistStore(store);
  // return { store, persistor };

  return store;
}
// #endregion
github tabwrangler / tabwrangler / app / js / configureStore.js View on Github external
return Promise.resolve(state);
    }
  },
  serialize: false,
  storage: localStorage,

  // Disable redux-persist timeout functionality so it never erroneously wipes out the store. That's
  // never desired no matter how long the timeout lasts.
  //
  // See https://github.com/rt2zz/redux-persist/issues/809#issuecomment-437589932
  timeout: 0,
  version: 2,
};

const rootReducer = combineReducers({
  localStorage: persistReducer(localStoragePersistConfig, localStorageReducer),
  tempStorage: tempStorageReducer,
});

export default function() {
  // $FlowFixMe
  const store = createStore(rootReducer, applyMiddleware(thunk));
  return {
    persistor: persistStore(store),
    store,
  };
}
github sebastienbarbier / seven23_webapp / src / app / store.js View on Github external
import { createStore, applyMiddleware } from "redux";
import { persistStore, persistReducer } from "redux-persist";
import storage from "redux-persist/lib/storage"; // defaults to localStorage for web and AsyncStorage for react-native

import thunk from "redux-thunk";

import rootReducer from "./reducers";

const persistConfig = {
  key: "root",
  storage,
  blacklist: ["state"]
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

let store = createStore(persistedReducer, applyMiddleware(thunk));
let persistor = persistStore(store);

export { store, persistor };
github remigallego / winampify / js / store.ts View on Github external
const persistConfig = {
  key: "root",
  version: 0,
  storage,
  whitelist: ["auth"],
  transforms: [transform],
  // @ts-ignore
  migrate: createMigrate(migrations, { debug: false })
};

const compose = composeWithDevTools({});

const logger = createLogger({});

const persistedReducer = persistReducer(persistConfig, reducer);
let middlewares;

if (process.env.NODE_ENV === "development") {
  middlewares = compose(applyMiddleware(thunk, logger));
} else {
  middlewares = applyMiddleware(thunk);
}

const store = createStore(
  persistedReducer,
  initialStateApp,
  middlewares
);

export default store;
github lematt1991 / BeerFeed / mobile / Store.js View on Github external
import {createStore, combineReducers, applyMiddleware, compose} from 'redux'
import API from './middleware/API'
import ChangeFeed from './middleware/ChangeFeed'
import Debounce from './middleware/Debounce'
import {createLogger} from 'redux-logger'

import { persistStore, persistCombineReducers, persistReducer } from 'redux-persist'
import storage from 'redux-persist/es/storage'
import { AsyncStorage } from 'react-native';

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

const reducer = persistReducer(config, combineReducers({
	search,
  settings,
  data,
  location,
  user,
}))

const middleware = applyMiddleware(
	API, 
	ChangeFeed,
	Debounce
	// ,createLogger()
)

export const store = createStore(reducer, middleware);
export const persistor = persistStore(store, {});
github SocialXNetwork / socialx_react_native / packages / RNSocialX / src / store / configureStore.ts View on Github external
export const configureStore = (
	depsConfig: IContextConfig,
	appConfig: IApplicationConfig,
	bugsnag: Client,
) => {
	const persistedReducer = persistReducer(persistConfig, rootReducer);
	const dataApi = dataApiFactory({
		peers: depsConfig.dataApi.peers.map((peer: string) => `http://${peer}:8765/gun`),
		rootdb: depsConfig.dataApi.rootdb,
	});

	const storageApi = storageApiFactory(
		{
			host: appConfig.ipfsConfig.ipfs_server,
			port: appConfig.ipfsConfig.ipfs_port,
			protocol: appConfig.ipfsConfig.opts.protocol,
			root: appConfig.ipfsConfig.opts.root,
		},
		Platform.OS,
	);

	const store = createStore(
github anchetaWern / RNOffline / src / screens / RehydrateScreen.js View on Github external
import storage from "redux-persist/lib/storage";
import { PersistGate } from "redux-persist/integration/react";

import { reducer } from "../redux";
import { watcherSaga } from "../sagas";

import PokemonLoader from "../components/PokemonLoader";

const sagaMiddleware = createSagaMiddleware();

const persistConfig = {
  key: "root",
  storage
};

const persistedReducer = persistReducer(persistConfig, reducer);

const store = createStore(persistedReducer, applyMiddleware(sagaMiddleware));
let persistor = persistStore(store);

sagaMiddleware.run(watcherSaga);

export default class RehydrateScreen extends Component {
  static navigationOptions = {
    title: "Rehydrate"
  };

  render() {
    return (
github pietrzakadrian / bank / app / reducers.js View on Github external
export default function createReducer(injectedReducers = {}) {
  const rootReducer = combineReducers({
    global: persistReducer(globalPersistConfig, globalReducer),
    language: persistReducer(languagePersistConfig, languageProviderReducer),
    router: connectRouter(history),
    ...injectedReducers,
  });

  return rootReducer;
}