redux-persist 5.x在API中进行了更改,并且不再使用autoRehydrate。下面是我现在使用redux-persist的方法。
import React, {Component} from 'react';import {Provider} from 'react-redux';import {createStore, applyMiddleware, compose} from 'redux';import {PersistGate} from 'redux-persist/lib/integration/react';import {persistStore, persistReducer} from 'redux-persist';import storage from 'redux-persist/lib/storage';import Thunk from 'redux-thunk';import Router from './Router';import reducers from './reducers';const persistConfig = { key: 'root', storage: storage,};const persistedReducer = persistReducer(persistConfig, reducers);const store = compose(persistedReducer, {}, composeEnhancers(applyMiddleware(Thunk)));class App extends Component { render() { const persistor = persistStore(store); return ( <Provider store={store}> <PersistGate persistor={persistor}> <Router /> </PersistGate> </Provider> ); }}export default App;

![[RN] [Redux [RN] [Redux](http://www.mshxw.com/aiimages/31/377917.png)
