Skip to content

Immutable with Nested #34

Open
Open
@djeeg

Description

@djeeg

Hi,

I'm trying to use both immutable state and nested persists (for code splitting)
https://github.com/rt2zz/redux-persist#nested-persists
https://github.com/rt2zz/redux-persist-transform-immutable

Config looks like this:

const rootPersistConfig = {
  key: 'root',
  storage: storage,
  whitelist: []
}
const content1PersistConfig = {
  key: 'content1',
  storage: storage1,
  transforms: [immutableTransform({records: [Content1Record]})],
}
const content2PersistConfig = {
  key: 'content2',
  storage: storage2,
  transforms: [immutableTransform({records: [Content2Record]})],
}

const rootReducer = combineReducers({
  content1: persistReducer(content1PersistConfig, content1Reducer),
  content2: persistReducer(content2PersistConfig, content2Reducer),
})
export default persistReducer(rootPersistConfig, rootReducer)

State tree looks something like this

var rootstate = {
	content1: Content1Record{
		variable1,
		variable2,
	},
	content2: Content2Record{
		variable3,
		variable4,
	},
}

As per the README, top level state is not an ImmutableMap/Record (its plain object)

What I am finding, with default state, the Immutable Record is getting corrupted during the first PERSIST action dispatch
It looks like it is this line
https://github.com/rt2zz/redux-persist/blob/master/src/persistReducer.js#L66

Starts off as a healthy Immutable Record

_ref => Content1Record { variable1: false, variable2: "detail" }

Out comes an invalid object (looks like an Immutable List)

restState => { __ownerID: undefined, _values: List [ false, "detail" ] }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions