Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 672 Bytes

52_persistent.md

File metadata and controls

22 lines (16 loc) · 672 Bytes

5.2 Persistent

1.AsyncStorage

2.apply redux-persist middlewear

import { AsyncStorage } from 'react-native';
import { applyMiddleware, createStore, compose } from 'redux';
import thunk from 'redux-thunk';
import {persistStore, autoRehydrate} from 'redux-persist';
import reducers from '../reducers';

var middlewares = compose(applyMiddleware(thunk), autoRehydrate());

export default function configureStore() {
  const store = createStore(reducers, undefined, middlewares);
  persistStore(store, {storage: AsyncStorage});
  return store;
}