4 ms·
Can you expand on "You just need to be careful not to use the vanilla reducer composer from Redux." a bit more? Is that 'combineReducers' from Redux? What's wr
by darklajid 11y ago
Can you expand on "You just need to be careful not to use the vanilla reducer composer from Redux." a bit more? Is that 'combineReducers' from Redux?
What's wrong with that? What are the alternatives?
- jonesetc 11y agocombineReducers is for taking plain objects and returning another plain object. With immutable you need to either write your own combineReducers or use one that someone else has made that taks immutable objects and returns an immutable object.
- darklajid 11y agoWait - we're talking about the result of the combination? If you follow a 'get started with redux' thing and end up with a root reducer that uses combineReducers: You're talking about the outermost 'state' object? Because any reducer that you write can certainly accept/understand/return immutables, right? If I picked that up correctly: Is that a problem for a single combineReducers at the root? Because if all the properties of that thing are immutable, wouldn't you get the cheap identity based comparison benefits whenever you pass on props.foo in your store-aware component?
- danmaz74 11y agoYes, it's the actual combiner that can't create an Immutable object.
- danmaz74 11y agojonestetc already explained the gist of it - combineReducers expects vanilla javascript objects, not Immutable ones; you can find an example Immutable-compatible implementation here: https://github.com/gajus/redux-immutable https://github.com/gajus/redux-immutable We don't use it though, it's really easy to just create your own version and use that and preferred to have one less dependency.