redux-persist-transform-immutable icon indicating copy to clipboard operation
redux-persist-transform-immutable copied to clipboard

top level immutable support pls.

Open 447491480 opened this issue 7 years ago • 6 comments

is there any plan to support top level immutable ?

447491480 avatar Jun 15 '18 02:06 447491480

+1 :(

krailler avatar Jul 31 '18 08:07 krailler

+1

antonsivogrivov avatar Aug 17 '18 12:08 antonsivogrivov

+1

MartinGian avatar Aug 29 '18 20:08 MartinGian

I think the relevant snipped is this:

    var _ref = state || {},
        _persist = _ref._persist,
        rest = _objectWithoutProperties(_ref, ['_persist']);
    var restState = rest;

    if (action.type === PERSIST) {
...
      getStoredState(config).then(function (restoredState) {
...
      }, function (err) {
...
      });

      return _extends({}, baseReducer(restState, action), {
      });
    }

It's when baseReducer(restState, action) is called we see this Uncaught TypeError: n.withMutations is not a function. There's no way to fix it using transforms because transforms are called from getStoredState and it isn't called to get restState. For some reason _objectWithoutProperties is used so it's POJO and doesn't have any methods. That's probably why we see this note:

if your top level state is an immutable map, this module will not work.

So how to fix it? Let's read v5 migration guide: https://github.com/rt2zz/redux-persist/blob/master/docs/MigrationGuide-v5.md

state methods can no longer be overridden which means all top level state needs to be plain objects. redux-persist-transform-immutable will continue to operate as before as it works on substate, not top level state.

And here's the issue describing various workarounds: https://github.com/rt2zz/redux-persist-immutable/issues/33

Well, that's bad I suppose.

Vanuan avatar Sep 10 '18 12:09 Vanuan

I hope we are talking about the same: for top-level-immutable supporting. Feel free to comment, find bugs, and ask questions.

OneStromberg avatar Jan 29 '19 07:01 OneStromberg

+1

geroale avatar Mar 31 '20 16:03 geroale