How to use the redux-persist.createPersistor 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 xkawi / react-universal-saga-modular / src / client.js View on Github external
const persistConfig = {
    whitelist: ['entities', 'pagination']
  };

  // window.__data = initial state passed down by server to client
  let initialState = window.__data; // eslint-disable-line
  try {
    const restoredState = await getStoredState(persistConfig);
    initialState = merge({}, initialState, restoredState);
  } catch (error) {
    console.log('error restoring state:', error);
  }

  const dest = document.getElementById('content');
  const store = configureStore(history, initialState);
  const persistor = createPersistor(store, persistConfig); // eslint-disable-line

  store.runSaga(rootSaga);

  render(
    ,
    dest
  );

  if (process.env.NODE_ENV !== 'production') {
    window.React = React; // enable debugger
  }
}
github 10086XIAOZHANG / CP-WEB-SOURCE-PlATFORM / src / app.js View on Github external
// 5. 启动应用
app.start('#root');

localForage.config({
  ...config,
});

persistStore(app._store, {
  storage: localForage,
  keyPrefix: 'webend:',
  whitelist: ['global'],
});

// secondaryPersistor
createPersistor(app._store, {
  keyPrefix: 'webend:',
  whitelist: ['global'],
});
github reduxjs / redux-devtools / packages / redux-devtools-core / src / app / store / configureStore.js View on Github external
}
      if (module.hot) {
        // Enable Webpack hot module replacement for reducers
        module.hot.accept('../reducers', () => {
          const nextReducer = require('../reducers'); // eslint-disable-line global-require
          store.replaceReducer(nextReducer);
        });
      }
    }

    const store = createStore(
      rootReducer,
      restoredState,
      composeEnhancers(applyMiddleware(exportState, api))
    );
    const persistor = createPersistor(store, persistConfig);
    callback(store, restoredState);
    if (err) persistor.purge();
  });
}
github DefinitelyTyped / DefinitelyTyped / redux-persist-transform-compress / redux-persist-transform-compress-tests.ts View on Github external
import { createStore, Reducer, Store } from "redux"
import { createPersistor, Transform } from "redux-persist"
import createCompressor = require("redux-persist-transform-compress")

const reducer: Reducer = (state: any, action: any) => ({ state, action })

const compressor: Transform = createCompressor({ whitelist : ["foo"] })

const store: Store = createStore(reducer)

createPersistor(store, { transforms : [compressor] })
github DefinitelyTyped / DefinitelyTyped / redux-persist-transform-filter / redux-persist-transform-filter-tests.ts View on Github external
import { createStore, Reducer, Store } from "redux"
import { createPersistor, Transform } from "redux-persist"
import createFilter from "redux-persist-transform-filter"

const reducer: Reducer = (state: any, action: any) => ({ state, action })

const filter: Transform = createFilter(
    "foo",
    ["foo.bar"],
    ["fizz.buzz"]
)

const store: Store = createStore(reducer)

createPersistor(store, { transforms : [filter] })
github DefinitelyTyped / DefinitelyTyped / redux-persist-transform-encrypt / redux-persist-transform-encrypt-tests.ts View on Github external
import { createStore, Reducer, Store } from "redux"
import { createPersistor, Transform } from "redux-persist"
import { EncryptorConfig } from "redux-persist-transform-encrypt"
import createEncryptor from "redux-persist-transform-encrypt"
import createAsyncEncryptor from "redux-persist-transform-encrypt/async"

const reducer: Reducer = (state: any, action: any) => ({ state, action })

const config: EncryptorConfig = { secretKey : "foo" }
const encryptor: Transform = createEncryptor(config)
const asyncEncryptor: Transform = createAsyncEncryptor(config)

const store: Store = createStore(reducer)

createPersistor(store, { transforms : [encryptor, asyncEncryptor] })
github iotaledger / trinity-wallet / src / shared / migrations.js View on Github external
.then(() => {
            const incomingState = state.getState();

            const updatedState = updateSafely(incomingState, restoredState, config.blacklist);

            const persistor = createPersistor(state, config);
            persistor.rehydrate(updatedState);

            return persistState(state, config, cb);
        })
        .catch(() => persistState(state, config, cb));
github rt2zz / redux-persist-immutable / src / index.js View on Github external
const createPersistor = (store, config = {}, ...args) => {
  return baseCreatePersistor(store, extendConfig(config), ...args)
}