我正在尝试将 redux-storage 和 redux-saga 中间件用于 redux。每个中间件单独工作都很好,但是当我使用 redux-saga 应用 redux-storage 时,存储不会加载先前的状态。我添加中间件如下:
const combinedReducers = storage.reducer(combineReducers(reducers));
import createEngine from 'redux-storage-engine-reactnativeasyncstorage';
const engine = createEngine('storage-key');
const storageMiddleWare = storage.createMiddleware(engine);
const sagaMiddleWare = createSagaMiddleware(mySagas);
export const store = createStore(combinedReducers, applyMiddleware( sagaMiddleWare, storageMiddleWare));
const load = storage.createLoader(engine);
load(store).then(() =>
{
console.log("Loaded State");
console.log(store.getState());
}).done();