Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transform-immutable not working with transform-encrypt (v5 issue) #35

Open
Flollipop opened this issue May 9, 2018 · 1 comment
Open

Comments

@Flollipop
Copy link

Flollipop commented May 9, 2018

Hi,

I facing some issues to use transform-immutable and transform-encrypt with redux-persist v5.

I managed to use transform-immutable alone.

But when I try to use encrypt with it I get some issues.

in the persist's config file:

const persistConfig = {
   transforms: [ encryptor, immutableTransform() ],
   key: 'root',
   storage: storage,
   debug: true
};

Give an object state (immutable not working when get data from storage). It's like immutableTransform return exactly what it get from encryptor.

So it seems when writing transform-encrypt accept transform-immutable data but when reading immutable-transform does nothing.

const persistConfig = {
	transforms: [ immutableTransform(),  encryptor],
	key: 'root',
	storage: storage,
	debug: true
};

Give an empty state after attempting rehydratation.

If found some old related issues, but seems code is not the same now.
maxdeviant/redux-persist-transform-encrypt#2

An idea where the conflict between this two package can be?
Is it relevant to update encrypt or immutable, or create an transform between this two?

Thank you for your work.

@Flollipop
Copy link
Author

Flollipop commented May 15, 2018

In the first time I've tried a dumy custom temporary transform between encrypt and immutable, pending v5 support

const myV4ToV5Transform = createTransform( 
	(inboundState, key) => JSON.parse(inboundState),
	
	(outboundState, key) => JSON.stringify(outboundState)
);

const persistConfig = {
	transforms: [ immutableTransform(), myV4ToV5Transform, encryptor ],
	key: 'root',
	storage: storage,
	debug: true
};

after some reflexion I came with this solution using immutable functions, to completely replace immutable Transform.

export const myImmutableTransform = createTransform(
	(inboundState) => inboundState.toJS(),

	(outboundState) => fromJS(outboundState),

	{ blacklist: [ '_persist' ] }
);

@Flollipop Flollipop changed the title transform-immutable not working with transform-encrypt transform-immutable not working with transform-encrypt (v5 issue) Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant