ngrx-store-localstorage icon indicating copy to clipboard operation
ngrx-store-localstorage copied to clipboard

Rehydrate causes unrelated keys not visible in the store

Open MikeDabrowski opened this issue 1 year ago • 2 comments

my sync config:

const localStorageSyncConfig: LocalStorageConfig = {
  keys: [{ appState: ['mode'] }],
  rehydrate: true,
  storageKeySerializer: (key: string) => `ngrx-sync-${key}`,
};

my store (relevant piece)

export const initialState: AppState = {
  mode: Mode.Light,
  countries: [],
  version: undefined,
  build: undefined,
  edition: undefined,
  test: 'undefined',
  localStorage: {
    restorePdfTooltipDismissed: true,
  },
};

And after the app starts. The store does not have test and localStorage properties at all. Even though they were not mentioned in the config. The properties that are in the store are set later (after rehydration) via various other actions. The missing ones I added while debugging, they are only in the initialState, not mentioned in other places.

I'd expect them to be ignored because they are not mentioned in the config. I am now afraid to use this tool because it can remove other properties too.

Actually it is a duplicate of: https://github.com/btroncone/ngrx-store-localstorage/issues/268

MikeDabrowski avatar Sep 09 '24 17:09 MikeDabrowski