-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
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
Question: Should I use immutable data structures #1422
Comments
Finally, you don't need any library to use Immutable with Redux. They just give you Immutable-first combineReducers. You can use it or you can write your own. Check their source code and you will see there is nothing fancy going on there. I'm not aware of any problems caused by them so I don't know what you are referring to. |
@gaearon thanks for answering! I feel comfortable about using Immutable.js but I don't feel like I need it at all times. I work with some people that is just getting started with Redux and sometimes the new joiners perform some bad mutations. To prevent this I was considering using immutablejs. The problem is that once they get familiar with Redux we probably won't need it and it will affect performance. That's why I was wondering if something like |
Immutable still leaves plenty of pitfalls for beginners: they can put stuff as instance fields on immutable object, they can forget to
What will affect performance? If anything, Immutable should give you a better performance than plain objects. This is the main reason people like to use it.
No better way than to try and tell us. 😉 You can also create a similar middleware that would deep-freeze state and action objects. |
Thanks a lot for that 👍 I will comment on this in a few months from now to share how did it go 🍀 |
Hi,
I'm considering doing something to prevent bad state mutations. The first thing that I though about was immutable but then I started to think about the potential performance implications.
Some immutable checks will decrease performance because they are adding some run-time overhead. At the same time using immutable could improve performance when used in places like
shouldComponentUpdate
:So my main question are:
I was also trying to find out how to integrate immutable.js with Redux and I found two libraries:
Both libraries force you to use their custom implementation of
combineReducers
but there seems to be some problems with the reducers and middle-ware.I have seem examples that use Redux + immutable.js without
redux-immutable
orredux-immutablejs
so I'm not fully sure about those being really needed.The text was updated successfully, but these errors were encountered: