我在ReduxPersist的GitHub页面上找不到任何信息。
我有一段代码想要理解,由于autoRehydrate
已被移除,我想知道如何使用redux-persist
的版本5来实现该代码。
import { AsyncStorage } from 'react-native';
import { applyMiddleware, createStore } from 'redux';
import { autoRehydrate, persistStore } from 'redux-persist'
import thunk from 'redux-thunk';
import reducers from '../reducers';
const middleWare = [thunk];
const createStoreWithMiddleware = applyMiddleware(...middleWare)(createStore);
export default configureStore = (onComplete) => {
const store = autoRehydrate()(createStoreWithMiddleware)(reducers);
persistStore(store, { storage: AsyncStorage }, onComplete);
return store;
};
我找到了一些教程,但它只是说必须有 autoRehydrate
,但并没有解释它实际上是做什么的。