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

Documentation: es6 Map and Set in the state are not documented #1499

Closed
andruhon opened this issue Mar 8, 2016 · 6 comments

Comments

@andruhon
Copy link

commented Mar 8, 2016

I did not find in the documentation how one should or should not use things like es6 Map and Set with Redux.

It seems like a new map should be created every time when we 'modify' it in the reducer, but I'm not sure that it is correct.

@gaearon

This comment has been minimized.

Copy link
Contributor

commented Mar 8, 2016

I don’t think it’s a good idea to use them in Redux because they are optimized for mutability. If you want to have something efficient with similar semantics, consider using Immutable.js.

@gaearon gaearon closed this Mar 8, 2016

@andruhon

This comment has been minimized.

Copy link
Author

commented Mar 8, 2016

Can this be mentioned somewhere in the docs, that it is not a good idea? (probably this issue is enough to be googled by keywords)

@mohammedabualsoud

This comment has been minimized.

Copy link

commented Jul 16, 2017

Yes, I'm not able to use ES6 map it seems it just deal with Objects, and array only.

@markerikson

This comment has been minimized.

Copy link
Contributor

commented Jul 16, 2017

You can use Maps and Sets as state values, but it's not recommended due to serializability concerns. In addition, the built-in combineReducers utility expects to work with plain JS objects, so if you use a Map as part of your state tree, you would need to use other reducer handling instead of combineReducers.

@adrienjt

This comment has been minimized.

Copy link
Contributor

commented Aug 22, 2017

@reduxjs reduxjs deleted a comment from ChuckJonas Mar 29, 2018

@ChuckJonas

This comment has been minimized.

Copy link

commented Apr 28, 2018

Not sure if this is what @markerikson means by "serializability concerns", but for example if you try to do things like export/import your entire state with json, any maps in your reducer state will not properly be initialized. The basic issue is outlined here: http://2ality.com/2015/08/es6-map-json.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
6 participants
You can’t perform that action at this time.