Skip to content

Partial initial state and usage help / docs #17

@damianobarbati

Description

@damianobarbati

@edy thanks for this repo!
It seems the rehydration is not properly dealing with defaults when using transforms.

Here my default state:

const defaultState = {
    computing: [],
    notification: null,
    token: null,
    data: {},
};

Here the persist transforms applied (I want only main.token to be persisted):

import { createFilter, createWhitelistFilter, createBlacklistFilter } from 'redux-persist-transform-filter';

const loadFilter = createWhitelistFilter('main', ['token']);

const persistConfig = {
    key: 'user',
    keyPrefix: 'user/',
    transforms: [loadFilter]
};

What happens after rehydrate dispatch is the following:

{
  main: {
    token: 'blabla'
  },
  _persist: {
    version: -1,
    rehydrated: true
  }
}

Since data:{} default is not applied but totally removed because ignored in the transform I get errors.

How can I deal with this situation? Persist just wanted keys and apply defaults to the others?
Would it be possible to always rehydrate to the default and then apply the rehydration of wanted subkeys?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions