rt2zz / redux-persist

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

Simply clear cached storage on new version #1350

Open simplenotezy opened 2 years ago

simplenotezy commented 2 years ago

From experience with working with other persistor libraries, when changing version the default behavior is that it will simply wipe whatever is in the localstorage.

I was trying to search around to get this functionality but it seems very difficult. It's not clear exactly how the migrator works from the documentation, but to me it seems to run on every load, no matter if version has changed or not.

Did anybody implement this feature in their own projects, who care to share some code?

codingedgar commented 2 years ago

@simplenotezy I followed https://github.com/rt2zz/redux-persist/blob/master/docs/migrations.md and everything works fine, from: https://github.com/rt2zz/redux-persist/blob/57d1c6ccd37dd8dcfd30f6485e6b35baf5a8f51f/src/createMigrate.ts#L25-L28 (and my exp)

it does not run migrations all the time, just when an "old" version is detected (from a new code)