Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

top level immutable support pls. #36

Open
447491480 opened this issue Jun 15, 2018 · 6 comments
Open

top level immutable support pls. #36

447491480 opened this issue Jun 15, 2018 · 6 comments

Comments

@447491480
Copy link

is there any plan to support top level immutable ?

@krailler
Copy link

+1 :(

@antonsivogrivov
Copy link

+1

1 similar comment
@MartinGian
Copy link

+1

@Vanuan
Copy link

Vanuan commented Sep 10, 2018

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: rt2zz/redux-persist-immutable#33

Well, that's bad I suppose.

@OneStromberg
Copy link

OneStromberg commented Jan 29, 2019

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

@geroale
Copy link

geroale commented Mar 31, 2020

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants