Open magrinj opened 4 years ago
@magrinj Thanks for your solution!
Another solution without 3-rd party libraries (via the spread operator):
createTransform(
// hydration (inbound)
(inboundState, key) => {
const { activities, photos, users, ...restOfInboundState } = inboundState;
return restOfInboundState;
},
// rehydration (outbound)
(outboundState, key) => {
return { ...outboundState };
},
{ whitelist: ['entities'] }
);
Why would you return { ...outboundState }
rather than just return outboundState
?
I was using this library to blacklist a part of my reducer state. This lead in big performances issues, using a simple blacklist filter like this one:
With this filter, app became really slow ! The amount of datas is equivalent to 33kb.
So I use this custom filter that is doing the same:
And the app works well for now, maybe it's related to the
cloneDeep
of this library when the state grow. This library should usepick
andomit
from lodash, as this two functions are working with path and avoid cloning state !