0

我已经添加,redux 坚持到我的应用程序。我有一个根减速器,其中包含不同的减速器,如“Auth”、“Orders”、“Products”、“Transactions”等。

问题是我的 Orders and Products reducer 已正确保留,但 Auth 和 Transactions reducer 没有保留。

我试过调试,我在 root reducer 的 Auth 和 Transactions 切片中看不到任何数据

这是我的顶级配置

const persistConfig = {
  key: 'root',
  storage,
  // blacklist: ['navigation']   pass state which you want to ignore
  blacklist: ['navigation', 'Error', 'Address', 'form'],
  stateReconciler: autoMergeLevel2,
};
const pReducer = persistReducer(persistConfig, rootReducer);

出口喜欢

export const configureStore = createStore(pReducer, composeEnhancers(applyMiddleware(thunk)));
export const persistor = persistStore(configureStore);

在我的 App.js 中


  <Provider store={store}>
      {/* the loading and persistor props are both required! */}
        <PersistGate loading={<Spinner />} persistor={persistor}>
           <CommuneVendorRoot />
       </PersistGate>
   </Provider>
4

1 回答 1

0
import { persistCombineReducers } from 'redux-persist'
import storage from 'redux-persist/es/storage'
import todos from '../reducers/reducers';
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';

console.log(todos)
const config = {
  key: 'root',
  storage: storage,
  debug: true,
  stateReconciler: autoMergeLevel2
};


const rootReducer = persistCombineReducers(config, {
  Transactions: todos
});
export default rootReducer;

请检查上面的代码它工作正常。如果您还有任何问题,请告诉我

于 2019-02-09T10:23:05.833 回答