I'm using redux-persist with AsyncStorage in a React Native app. I'm noticing that sometimes, after dispatching an action, the data is updated in the store, but not persisted. It usually happens after a fresh install or hard close of the app. This only happens on Android, on iOS everything works fine.
Scenario:
Fresh app install => AsyncStorage empty
Dispatch setSeenVoucherIds action for the first time => the store is updated and this is reflected in the app (selectSeenVoucherIds selector). However, nothing was actually persisted. After hard-closing the app, the selectSeenVoucherIds selector shows the initial value instead of the value that was set before.
Dispatch setSeenVoucherIds action for the second time => now, the value is persisted
I'm probably doing something wrong but I can't see what. Any help is appreciated.
After further investigation, it was related to the resetAction action we defined, which was being called erroneously. Closing this, apologies for any effort spent on your part.
I'm using redux-persist with AsyncStorage in a React Native app. I'm noticing that sometimes, after dispatching an action, the data is updated in the store, but not persisted. It usually happens after a fresh install or hard close of the app. This only happens on Android, on iOS everything works fine.
Scenario:
setSeenVoucherIds
action for the first time => the store is updated and this is reflected in the app (selectSeenVoucherIds
selector). However, nothing was actually persisted. After hard-closing the app, theselectSeenVoucherIds
selector shows the initial value instead of the value that was set before.setSeenVoucherIds
action for the second time => now, the value is persistedI'm probably doing something wrong but I can't see what. Any help is appreciated.
Using: @reduxjs/toolkit@2.2.3 react-redux@9.1.1 redux-persist@6.0.0
seenVouchersSlice.ts
store.ts:
And lastly App.tsx: