Integrating redux-simple-router
https://github.com/jlongster/redux-simple-router
Although I find redux-simple-router to be very elegant - I dislike the fact that it prevents you from using immutablejs Map as your state. That's because of this line: https://github.com/rackt/redux-simple-router/blob/master/src/index.js#L43
Once you let libraries like redux-(simple-)router manipulate your state you have to make your state a simple JS object. If you choose to use Immutablejs for the benefits of strict immutability - you need to wrap it with an object - and it's truly annoying.
I'm not currently using Immutable JS because I'm not sure why I should include it. What are the benefits?
I wanted a way to prevent state manipulation - and the subtle bugs that follow. For example - if during shouldComponentUpdate you compare your previous state to the new state - you'll always get equality because it's the same instance. This sort of "defensive" design is sometimes necessary when working with a team.
Also, using an API such as ImmutableJS' makes you stop and think of things like 1. where do you perform the state manipulation (you don't want to start importing immutablejs everywhere) and 2. what's the cost of the manipulation (copying huge collections much?).
Lastly - some strong functionality out of the box (things you'll usually use lodash for).
I'm not saying you should use ImmutalbeJS - but take into account that enough projects use it for it to be a consideration.
I see what you mean. And how does the Object.assign in redux-simple-router interfere with that?
Short answer: Object.assign returns an object - not an Immutable.Map. So you have a Map as your state and after their reducer is called you suddenly have a simple object.
The idea behind redux-simple-router (and also redux-router) is to take your state object and add their own subtree for routing state. But they assume your root state instance is of an object type. They can simply change it by allowing you to provide a custom reducer - and I opened a bug.
Ah I see, thanks very much for the info, I didn't consider that at all!
I won't be including redux-simple-router then, lets revisit this when https://github.com/rackt/redux-simple-router/issues/140 is added!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.