Redux Store
When Modify Redux Store, How to fix Redux-Persist Confliction
Redux Store is the state of your javascript application. Every code access store for read-only global but not every code change or update state. Defined actions only access store reducers and updates state. It’s beneficial and easy to manage state.
Redux Persist is a library for redux. It persists from Redux Store to LocalStorage. When the application starts, it loads data from LocalStorage to Redux Store and updates according to fetching new data from a server or user updates. Everything ok, but when you have to change the reducer structure in the store. When clients/users load a new version of applications. It conflicts with LocalStorage Redux Store Structure and Loaded Redux Structure. How can fix it?
Below are helpful links that explain this content very detail. There are different solutions State Reconciler, Migration, or Transform. I think the simplest solution to the problem is State Reconciler;
autoMergeLevel2: holds initial value and merges with local storage value. For example, in your version1 store, you have queries[] and a new version versiyon2, this name is queriesA[], and also age pageNo after a merge, you have all of them in-store. So your application uses queriesA[] and pageNo. queries[] structure is useless, and it will clear when you exit/log out.
- queries[]
- queriesA[]
- pageNo
Useful Links
- Redux-Persist
- Redux-Persist Migration Example
- Definitive Guide to Redux-Persist
- Redux Persist: How it works and how to change the structure of your persisted store
Let’s continue reading 😃
You can find similar samples and writings at this link if you like this story, please 👏👏 and share.