Skip to content

[Solved] Arrays being rehydrated as maps #36

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

Closed
phacks opened this issue Nov 23, 2017 · 0 comments
Closed

[Solved] Arrays being rehydrated as maps #36

phacks opened this issue Nov 23, 2017 · 0 comments

Comments

@phacks
Copy link

phacks commented Nov 23, 2017

Hi!

@gentholb & I stumbled on a tenacious problem yesterday, and after hours trying and succeeding in fixing it, we thought it would be interesting to document it here. The issue can be closed if need be.

The problem

When rehydrating, the arrays in our Redux store would be substituted by Immutable Maps.

Instead of this:

entities: [
  { index: 1 },
  { index: 2 }
]

The following structure was loaded into the store:

entities: {
  0: { index: 1 },
  1: { index: 2 }
}

This was breaking our app since we were using #Array.findIndex in our reducer, which does not work with Maps.

I had the following dependencies in my app :

"immutable": "3.8.1",
"redux-persist-immutable": "^4.3.1",
"redux-persist-transform-filter-immutable": "^0.3.0",

The solution

It turns out that the problem has been documented here and is caused by multiple Immutable versions being loaded in the app.

The https://github.com/ntucker/redux-persist-transform-filter-immutable library declares [email protected] as a dependency, which was causing Immutable to be loaded twice.

We then :

  • Migrated to the @actra-development-oss/redux-persist-transform-filter-immutable version of the plugin, which is the one linked from the README (but unfortunately not the one registered on NPM…), which declares [email protected] as a dependency
  • Updated our version of immutable to 3.8.2

Hope this can help!

Thanks

@phacks phacks closed this as completed Sep 10, 2018
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

1 participant