How to use the redux-persist/lib/storage.default 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 jellyfin / jellyfin-react-client / src / utilities / storage / normalStorage.ts View on Github external
import isElectron from "is-electron";

let storage: any;
// The only time IS_ELECTRON will be 1 is for the electron build.
if (isElectron()) {
    const createElectronStore = require("electron-store-webpack-wrapper").default;
    const createElectronStorage = require("redux-persist-electron-storage");
    const electronStore = createElectronStore({
        // your electron-store options here
    });
    storage = createElectronStorage({
        electronStore
    });
} else {
    storage = require("redux-persist/lib/storage").default;
}
export default storage;
github codejamninja / reactant / src / store / create.js View on Github external
function getStorage(context) {
  if (context.cookieJar) {
    const { CookieStorage } = require('redux-persist-cookie-storage');
    return new CookieStorage(context.cookieJar, {});
  }
  return require('redux-persist/lib/storage').default;
}
github jaggerwang / react-in-practice / store.js View on Github external
export function makeStore(initialState, { isServer }) {
  initialState = initialState || reducer()

  const middlewares = [thunk]
  if (publicRuntimeConfig.logReduxAction) {
    middlewares.push(logger)
  }
  const enhancer = composeWithDevTools(applyMiddleware(...middlewares))

  if (isServer) {
    return createStore(reducer, initialState, enhancer)
  } else {
    const { persistReducer, persistStore } = require('redux-persist')
    const storage = require('redux-persist/lib/storage').default

    const persistedReducer = persistReducer({
      key: 'jwpay',
      whitelist: ['common', 'form', 'account'],
      storage,
      migrate: state => {
        if (state && compareVersion(state.common.version, process.env.version, 2) !== 0) {
          state = initialState
        }
        return Promise.resolve(state)
      },
    }, reducer)
    const store = createStore(persistedReducer, initialState, enhancer)

    store.__persistor = persistStore(store)
github codejamninja / reactant / packages / base / src / createStore.js View on Github external
function getStorage(context) {
  if (context.cookieJar) {
    const { CookieStorage } = require('redux-persist-cookie-storage');
    return new CookieStorage(context.cookieJar, {});
  }
  return require('redux-persist/lib/storage').default;
}