Search code examples
reactjsreact-nativereduxredux-persistredux-offline

Redux Offline issue with rehydrating reducer to null


I am using redux-offline, below is how I am creating my store


let customConfig = {
    ...offlineConfig,
    persistOptions:{
        key: 'root',
        transforms: [immutableTransform()],
    },
    returnPromises : false,
    persistCallback : () => {this.setState({rehydrated : true})}
};

const { middleware, enhanceReducer, enhanceStore } = createOffline(customConfig);
let middlewares = applyMiddleware(offlineCommitHandler,thunk,middleware,);
store = createStore(enhanceReducer(IndexReducer),undefined,compose(enhanceStore,middlewares,persistAutoRehydrate({log:true})));

I have multiple reducers.

The issue occurs only in rehydrating one reducer, for ex : reducerA

I placed a debugger in autoRehydrate

  • When opening the app first time it merges the data for reducerA
  • When opening the app second time inbound state for reducerA is null.

Solution

  • For anyone looking for answer to similar issue.

    My issue was that the data i was trying to store was hitting the max storage limit for asyncStorage .

    https://github.com/rt2zz/redux-persist/issues/199

    I had to shift to using filestorage instead of asyncStorage to get redux persist store the data