5.2 Persistent

1.AsyncStorage

2.apply redux-persist middlewear

  1. import { AsyncStorage } from 'react-native';
  2. import { applyMiddleware, createStore, compose } from 'redux';
  3. import thunk from 'redux-thunk';
  4. import {persistStore, autoRehydrate} from 'redux-persist';
  5. import reducers from '../reducers';
  6. var middlewares = compose(applyMiddleware(thunk), autoRehydrate());
  7. export default function configureStore() {
  8. const store = createStore(reducers, undefined, middlewares);
  9. persistStore(store, {storage: AsyncStorage});
  10. return store;
  11. }

原文: https://unbug.gitbooks.io/react-native-training/content/52_persistent.html