How to use the redux-persist.createMigrate 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 csprance / MisRCON / src / redux / store.ts View on Github external
export const configureStore = () => {
  // redux-persist config
  const persistConfig = {
    version: 1,
    key: 'root',
    migrate: createMigrate(migrations as any, { debug: electronIsDev }),
    storage,
    transforms: [functionTransform, outputTransformers, passwordTransform],
    blacklist: ['notifications']
  };
  const persistedReducer = persistReducer(persistConfig, rootReducer);

  const composeEnhancers =
    (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;

  const middlewares = [thunk as ThunkMiddleware];

  if (electronIsDev) {
    middlewares.push(
      createLogger({
        predicate: (_, action) => !/^@@/.test(action.type),
        collapsed: true
github remigallego / winampify / js / store.ts View on Github external
const migrations = {
  0: (state: AppState) => {
    // migration clear out device state
    return initialStateApp;
  }
};

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(
github SuperblocksHQ / ethereum-studio / src / store / index.js View on Github external
import { createMigrate, persistStore, persistReducer } from 'redux-persist';
import { createEpicMiddleware, combineEpics } from 'redux-observable';
import storage from 'redux-persist/lib/storage'; // default: localStorage if web
import thunk from 'redux-thunk';
import migrations from './migrations';
import reducers from '../reducers';
import { epics } from '../epics';
import Backend from '../components/projecteditor/control/backend';

// Redux Persist config
const config = {
    key: 'root',
    storage,
    version: 5,
    whitelist: ['projects', 'settings'],
    migrate: createMigrate(migrations, { debug: true })
};

const combineReducers = reducers => {
    return (state = {}, action) => {

      // Reduce all the keys for reducers from `todos` and `visibilityFilter`
      return Object.keys(reducers).reduce(
        (nextState, key) => {
          // Call the corresponding reducer function for a given key
          nextState[key] = reducers[key] (
            state[key],
            action,
            // Let's make the entire state available to all reducers
            state
          );
          return nextState;
github SuperblocksHQ / ethereum-studio / packages / editor / src / store / index.js View on Github external
import { createMigrate, persistStore, persistReducer } from 'redux-persist';
import { createEpicMiddleware, combineEpics } from 'redux-observable';
import { loadingBarMiddleware } from 'react-redux-loading-bar'
import storage from 'redux-persist/lib/storage'; // default: localStorage if web
import thunk from 'redux-thunk';
import migrations from './migrations';
import reducers from '../reducers';
import { epics } from '../epics';

// Redux Persist config
const config = {
    key: 'root',
    storage,
    version: 5,
    whitelist: ['settings'],
    migrate: createMigrate(migrations, { debug: true })
};

const combineReducers = reducers => {
    return (state = {}, action) => {

      // Reduce all the keys for reducers from `todos` and `visibilityFilter`
      return Object.keys(reducers).reduce(
        (nextState, key) => {
          // Call the corresponding reducer function for a given key
          nextState[key] = reducers[key] (
            state[key],
            action,
            // Let's make the entire state available to all reducers
            state
          );
          return nextState;
github SuperblocksHQ / ethereum-studio / packages / dashboard / src / store / index.js View on Github external
import { createMigrate, persistStore, persistReducer } from 'redux-persist';
import { createEpicMiddleware, combineEpics } from 'redux-observable';
import { loadingBarMiddleware } from 'react-redux-loading-bar'
import storage from 'redux-persist/lib/storage'; // default: localStorage if web
import thunk from 'redux-thunk';
import migrations from './migrations';
import reducers from '../reducers';
import { epics } from '../epics';

// Redux Persist config
const config = {
    key: 'root',
    storage,
    version: 1,
    whitelist: [''],
    migrate: createMigrate(migrations, { debug: true })
};

const combineReducers = reducerList => {
    return (state = {}, action) => {

      // Reduce all the keys for reducers from `todos` and `visibilityFilter`
      return Object.keys(reducerList).reduce(
        (nextState, key) => {
          // Call the corresponding reducer function for a given key
          nextState[key] = reducerList[key] (
            state[key],
            action,
            // Let's make the entire state available to all reducers
            state
          );
          return nextState;
github textileio / notes / src / Redux / ReduxPersist.ts View on Github external
import { AsyncStorage } from 'react-native'
import { createMigrate, PersistConfig, MigrationManifest } from 'redux-persist'

const migrations: MigrationManifest = {
  0: (persistedState) => {
    const state = persistedState as any
    return state
  }
}

const persistConfig: PersistConfig = {
  key: 'primary',
  storage: AsyncStorage,
  version: 0,
  // whitelist: ['main'],
  migrate: createMigrate(migrations, { debug: true })
}

export default persistConfig
github tarassh / fairy-wallet / app / store / persist.js View on Github external
settings: newSettings
    });
  },
  3: state => {
    const { settings } = state;
    const newSettings = Object.assign({}, settings);
    newSettings.exchangeCurrency = 'usd';
  }
};

// configure persistor
const persistConfig = {
  version: 3,
  key: 'root',
  storage,
  migrate: createMigrate(migrations, { debug: true }),
  whitelist: ['settings', 'contacts'],
  debug: true
};

export default persistConfig;
github greymass / eos-voter / app / shared / store / shared / persist.js View on Github external
*/
  15: (state) => Object.assign({}, state, {
    blockchains: update014(state.blockchains),
  }),
  /*
   16 - Update default insights node
  */
  16: (state) => Object.assign({}, state, {
    blockchains: update016(state.blockchains),
  }),
};

const persistConfig = {
  key: 'eos-voter-config',
  version: 16,
  migrate: createMigrate(migrations, { debug: true }),
  storage: createElectronStorage(),
  timeout: 0, // The code base checks for falsy, so 0 disables
  whitelist: [
    'blockchains',
    'settings',
    'wallet',
    'wallets'
  ]
};

export default persistConfig;
github textileio / photos / App / Redux / RootReducer.ts View on Github external
}
  }
}

const persistConfig: PersistConfig = {
  key: 'primary',
  storage: AsyncStorage,
  version: 24,
  whitelist: [
    'account',
    'preferences',
    'deviceLogs',
    'initialization',
    'groups'
  ],
  migrate: createMigrate(migrations, { debug: false }),
  debug: false
}

const rootReducer = combineReducers({
  auth: authReducer,
  contacts: contactsReducer,
  updates: updatesReducer,
  groups: groupsReducer,
  preferences: preferencesReducer,
  photoViewing: photoViewingReducer,
  threads: threadsReducer,
  ui: uiReducer,
  startup: startupReducer,
  deviceLogs: deviceLogsReducer,
  account: accountReducer,
  textile: textileEventsReducer,
github textileio / photos / App / Config / ReduxPersist.ts View on Github external
...state,
      cameraRoll: {
        ...state.cameraRoll,
        pendingImageShares: [],
        pendingThreadShares: {}
      }
    }
  }
}

const persistConfig: PersistConfig = {
  key: 'primary',
  storage: AsyncStorage,
  version: 5,
  whitelist: ['preferences', 'uploadingImages', 'cameraRoll', 'contacts'],
  migrate: createMigrate(migrations, { debug: false })
}

export default persistConfig