redux-persist-immutable icon indicating copy to clipboard operation
redux-persist-immutable copied to clipboard

Handling updates to the format of the reducer that conflicts with local version

Open brandondurham opened this issue 8 years ago • 2 comments

Hi! I’m wondering if you have a suggestion around handling the use-case where there is a change in the format of the reducer? Development is heavy on my project right now and there are occasional changes to reducers. This often causes a conflict when the store is rehydrated using the localStorage state.

Example:

When changing the reducer’s initialState from this:

const initialState = fromJS({
	licenses: {
		oneLicenseType: {
			value: false
		},
		anotherLicenseType: {
			value: false
		},
		theLastLicenseType: {
			value: false
		}
	}
});

… to this:

const initialState = fromJS({
	licenses: {
		oneLicenseType: false,
		anotherLicenseType: false,
		theLastLicenseType: false
	}
});

I get the error “Cannot read property 'value' of undefined” when loading the page.

In this particular case where the app reducer format is different from the format in localStorage I would like to overwrite the local version.

Is this possible?

brandondurham avatar May 10 '17 16:05 brandondurham

I have same issue.

aglio avatar Jul 10 '17 08:07 aglio

I solved this issue by using this library. https://github.com/xiongxiong/redux-persist-version I found this library too, but that did not fit in my case. redux-persist-migrate seems that does not support immutable.js. https://github.com/wildlifela/redux-persist-migrate

aglio avatar Jul 10 '17 12:07 aglio