rt2zz / redux-persist

persist and rehydrate a redux store
MIT License
12.91k stars 863 forks source link

Question on production mobile app cached data #1348

Open Isaacmeedinaa opened 2 years ago

Isaacmeedinaa commented 2 years ago

Hey everyone,

I am currently developing an e-commerce management mobile application with React Native, and Redux. We persist data using redux-persist. This brings a great experience with cached data which is a principle in offline-first development.

But there might be a bug that can happen in the mobile world environment.

Let's assume that I have a reducer called "products". That reducer is just an array with product objects. The user logs in and now the data in that reducer is persisted. Later, my development team decides to update the mobile app with a new structure on that "products" reducer. The user's app gets updated, and now the persisted/cached data doesn't align with the new "products" reducer structure which leads to the app crashing.

I may be wrong, but is this an actual bug that can exist? If so, what is a work around or solution?

Thanks!

arakovskis commented 2 years ago

Hi, you will need to write migrations. https://github.com/rt2zz/redux-persist/blob/master/docs/migrations.md