Open gentlee opened 1 year ago
Lets say we have usersReducer that stores only current user:
export type UsersState = { currentUserId: string; profiles: Record<string, UserProfile>; }; export const usersReducer = persistReducer({ key: 'users', throttle: 5000, whitelist: ['currentUserId', 'profiles'], transforms: [ createTransform( (subState: UsersState['profiles'], _, state: UsersState) => { const currentUserId = state.currentUserId; return currentUserId ? { [currentUserId]: subState[currentUserId], } : {}; }, null, { whitelist: ['profiles'] }, ), ], }, reducer);
So it should call Storage.set only when current user changes. But no, it calls It every time when profiles state changes.
Storage.set
profiles
Is there a way to compare prev and new state before saving? Similar to mapStateToProps re-rendering.
Lets say we have usersReducer that stores only current user:
So it should call
Storage.set
only when current user changes. But no, it calls It every time whenprofiles
state changes.Is there a way to compare prev and new state before saving? Similar to mapStateToProps re-rendering.