1

I came across redux-immutable from official redux.js git book. It sounds pretty awesome, but how useful is it?

Noting: I love immutable js, that's why I'm even considering it.

Looking at its official documentation, I feel it has more con than pro, potentially.

The pro, for me, may just be uniformed state, no more forgetting "first level should not use immutableJS".

And that's about it.

  • I won't add or remove a reducer from my combineReducer() list.
  • I don't think there would be any performance improvement from using immutablejs at first level.

Note: Perhaps, it's a bit more useful if I have a hierarchical combineReducer() structure.

The con however, can be pretty annoying.

Like it said on its readme, react-router-redux will require a new custom reducer to work. There can be more plugins with similar strategy (based on assumption that mutable combineReducer is used), thus migrating can be pretty annoying. (especially for larger projects)


Is there any strong case to convince me to use it?

N.Xu
  • 131
  • 1
  • 7
  • What I can answer is that this library serves a purpose which solves a problem for some people. For others, depending on situation, it may be a nuisance. Whether this will be useful and worthwhile in your specific situation cannot be answered here and is purely speculation or opinion. The real answer is, if you think this might help, try it and find out. – caesay Nov 09 '17 at 06:14

1 Answers1

0

"useful" is global description like "good" "bad" "nice" etc. It doesn't have real value under it so it's impossible to answer with "yes" or "no". You need context.

I usually use ImmutableJs at state but not at the root level. I use ImmutableJS for one thing - quick comparison of data inside shouldComponentUpdate. There is no reason to have ImmutableJs at root level for this task.

I found that it introduces more typing, less readability and more complexity than needed and would not recommend using on the root level. While you may use other libs that don't expect to have ImmutableJs at root level.

I've built ~7 full applications from 0 to production ready with ReactJs during the last couple years and used ImmutableJs at root level of the state only for one small app.

Lukas Liesis
  • 24,652
  • 10
  • 111
  • 109
  • I know, I use immutableJS all the time as well. Just, I'm not sure how useful it is in redux's combineReducer() level. Is there enough benefit to counter the plugin compatibility problem it may raise. Inside each reducer, for me, it's a no brainer to use immutable JS for state. – N.Xu Nov 09 '17 at 11:11
  • I would not use immutable at root level, for all other state - sure. Please upvote & accept if it helped. – Lukas Liesis Nov 09 '17 at 11:12