redux-persist-transform-immutable
redux-persist-transform-immutable copied to clipboard
Uncaught Error: Error serializing unrecognized object [object Object]
UPDATE:
react-boilerplate immutable is using ArrayMapNode
which doesn't support toMap function
That why it produce below error.
Do you think it is possible to make it compatible?
I used react-boilerplate as a starter kit. It's using fromJS immutable as the store. I then try to add this library to make it persistence.
However, it have this error on my console.log
I'm not sure why does this happen, would you please advise?

This project is just a wrapper around https://github.com/glenjamin/transit-immutable-js
I would say if you need ArrayNodeMap support, it would be best to file an issue there.
Also I think the situation will be improved this week when we release redux-persist-immutable with top level immutable support.
Plug-an-Play support for react-boilerplate would be a delight.
I could figure out how the bug occurs.
It happens here https://github.com/rt2zz/redux-persist/blob/master/src/createPersistor.js#L57: stateGetter(store.getState(), key)
The default stateGetter doesn't access the immutable data structure key correctly (state[key]) so we get the wrong structure. A quick workaround for this is to pass your own getter and setter. Something like this should do the trick:
const enhancer = compose(
applyMiddleware(...middlewares),
autoRehydrate({
stateReconciler(state, inboundState, reducedState){
return state.merge(reducedState).merge(inboundState)
},
}),
]))
// ... other things ...
persistStore(store, {
storage: AsyncStorage,
transforms: [immutableTransform()],
_stateGetter: (state, key) => state.get ? state.get(key) : state[key],
_stateSetter: (state, key, value) => state.set ? state.set(key, value) : (state[key] = value, state),
_stateIterator: (state, callback) => state.keySeq().forEach(key => callback(state.get(key), key)),
})
Hope that it'll be useful for anyone else there facing the same issue!
I'm running into this issue currently, but only seeing the error in safari. Any idea why?