How to use the redux-persist.persistStore 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 open-apparel-registry / open-apparel-registry / src / app / src / configureStore.js View on Github external
/* eslint-disable no-underscore-dangle */
const devtoolsExtensionCompose = isDevelopment
    && isObject(window)
    && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
/* eslint-enable no-underscore-dangle */

const middleware = isDevelopment
    ? [thunkMiddleware, createLogger({ diff: true, collapsed: true })]
    : [thunkMiddleware];

const composeEnhancers = devtoolsExtensionCompose || compose;
const enhancer = composeEnhancers(applyMiddleware(...middleware));

export const store = createStore(rootReducer, enhancer);
export const persistor = persistStore(store);
github insiderdev / minimal-quotes / src / redux / store.js View on Github external
/* eslint-enable no-undef */

const enhancer = composeEnhancers(...enhancers);

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

const persistedReducer = persistReducer(persistConfig, reducer);
export const store = createStore(
  persistedReducer,
  {},
  enhancer,
);
export const persistor = persistStore(store);
github tubackkhoa / tkframework / mobile / Delivery / store / config.js View on Github external
const configureStore = callback =>   {  
  // mount it on the Store
  const store = createStore(
    rootReducer,
    initialState,
    compose(
      // if you use getStoredState then no need to use auto hydrate to get state back
      autoRehydrate(),
      applyMiddleware(...middleware),      
    )
  )

  // then run the saga
  sagaMiddleware.run(rootSaga)
  persistStore(store, {storage: AsyncStorage}, ()=> callback(store))
  
}
github rishabhbhatia / react-native-todo / app / redux / store / TodosStore.js View on Github external
import { AsyncStorage } from 'react-native';
import { createStore, applyMiddleware } from 'redux';

import { persistStore, autoRehydrate, purgeStoredState } from 'redux-persist';

import appReducer from '../reducers/AppReducer';


const todosStore = createStore(
  appReducer,
  undefined,
  autoRehydrate()
  );

persistStore(todosStore, {storage: AsyncStorage});
// purgeStoredState({storage: AsyncStorage})  // Clear persistStore

export default todosStore;
github nusmodifications / nusmods / website / src / bootstrapping / configure-store.ts View on Github external
}

  const storeEnhancer = applyMiddleware(...middlewares);

  const store: Store = createStore(
    rootReducer,
    defaultState,
    composeEnhancers(storeEnhancer),
  );

  if (module.hot) {
    // Enable webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => store.replaceReducer(rootReducer));
  }

  const persistor = persistStore(store);
  return { persistor, store };
}
github rock-solid / pwa-theme-woocommerce / src / configureStore.js View on Github external
cart,
  ),
  navbar,
  search,
  toastr,
});

const history = createHistory();

const store = createStore(
  rootReducer,
  undefined,
  applyMiddleware(thunk, routerMiddleware(history)),
);

persistStore(store);

export { history };
export default store;
github fttv-project / fttv / src / store / configureStore.ts View on Github external
const rootReducer = connectRouter(history)(reducer);
	const epicMiddleware = createEpicMiddleware(rootEpic);

	const enhancers = composeWithDevTools(
		applyMiddleware(
			routerMiddleware(history),
			epicMiddleware
		),
		autoRehydrate()
	);

	const store = initialState
		? createStore(rootReducer, initialState, enhancers)
		: createStore(rootReducer, enhancers);

	persistStore(store, {
		keyPrefix: "fttv:",
		whitelist: ["settings", "user"]
	});

	if ((process.env.NODE_ENV === "development") && module.hot) {
		module.hot.accept("data", () => {
			store.replaceReducer(connectRouter(history)(reducer));
			epicMiddleware.replaceEpic(rootEpic);
		});
	}

	return store;
};
github philipshurpik / react-native-starter-kit / app / store.js View on Github external
import {persistStore, autoRehydrate} from "redux-persist";
import {applyMiddleware, createStore, compose} from "redux";
import {AsyncStorage} from "react-native";
import thunk from "redux-thunk";
import createLogger from "redux-logger";
import rootReducer from "./rootReducer";

const logger = createLogger();

const store = createStore(rootReducer, compose(
	applyMiddleware(thunk, logger),
	autoRehydrate()
));

persistStore(store, {storage: AsyncStorage});

export default store;
github ASteinheiser / react-rpg.com / src / config / store.js View on Github external
});

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

const persistedReducer = persistReducer(persistConfig, rootReducer);

const store = createStore(
  persistedReducer,
  process.env.NODE_ENV === 'development' && window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
);

export default store;
export let persistor = persistStore(store);
github goodmind / treact / packages / treact / src / AppProvider.tsx View on Github external
public componentWillMount() {
    const onDone = () => this.setState({ rehydrated: true });
    persistStore(store,
      {whitelist: ['authKey', 'currentUser', 'currentDc']}, onDone);
  }