🎉 I'm releasing 12 products in 12 months! If you love product, checkout my new blog workingoutloud.dev

Back to home

Redux Persist With React Native

    yarn add redux-persist redux-persist-sensitive-storage

    import { persistStore, persistReducer } from "redux-persist"; import storage from "redux-persist/lib/storage"; import { PersistGate } from "redux-persist/es/integration/react"; // if you need to persist import createSensitiveStorage from "redux-persist-sensitive-storage"; Amplify.configure(config); const sagaMiddleware = createSagaMiddleware(); const enhancers = []; const reducers = combineReducers({ copy: CopyReducer, auth: AuthReducer, navigation: NavReducer, }); enhancers.push(applyMiddleware(logger, reduxNavMiddleware, sagaMiddleware)); // persist updates const persistConfig = { key: "primary", storage, whitelist: __DEV__ ? ["CopyReducer", "OffersReducer", "StoresReducer"] : [ "CopyReducer", "ProfileReducer", "OffersReducer", "StoresReducer", "LoyaltyCardReducer", ], }; const configuredReducers = persistReducer(persistConfig, reducers); const store = createStore(configuredReducers, composeEnhancers(...enhancers)); /* if you need sensitive storage */ const persistor = persistStore(store, createSensitiveStorage(), () => console.info("Persist configured") ); /* else */ // const persistor = persistStore(store); export default class App extends Component { render() { return ( <Provider store={store}> <PersistGate persistor={persistor}> <ReduxNavigation /> </PersistGate> </Provider> ); } }

    Personal image

    Dennis O'Keeffe

    @dennisokeeffe92
    • Melbourne, Australia

    Hi, I am a professional Software Engineer. Formerly of Culture Amp, UsabilityHub, Present Company and NightGuru.
    I am currently working on Visibuild.

    1,200+ PEOPLE ALREADY JOINED ❤️️

    Get fresh posts + news direct to your inbox.

    No spam. We only send you relevant content.

    Redux Persist With React Native

    Introduction

    Share this post