Closed mjangir closed 8 years ago
All of this is done for you if you use redux-bootstrap :D :electric_plug:
Can someone give an update on what needs to be done with the current version?
Personally I would not make the entire state immutable. IMO it is more trouble than it is worth especially when modules like react-router-redux
rely on the ability to update state. Instead I would recommend making state a plain object and have individual reducers return Immutable records, maps, or whatever you need.
@marshallford but still you will need a way to combine your individual reducers if they rely on the same data and hence combine immutablejs objects?
@jenyckee not quite sure what you are getting at but maybe this will help.
let reduxStore = {
user: Immutable.Record({}),
settings: Immutable.Map({}),
todos: Immutable.List([]),
router: ?
}
There are definitely some added conveniences for having the root state be a plain Object instead of an Immutable.Map. However, if you use this approach, then you have to remember this inconsistency, and it means extra work serialising state to storage, etc.
I prefer to keep the whole state either Immutable or plain (or something else). It isn't that difficult to insulate yourself from the inconsistencies with some helper functions, but I'd just rather keep everything the same.
I suggest seamless-immutable since it is easier to integrate and avoids polluting your code with ImmutableJS syntax.
I needed to install two npm packages:
immutable and immutable-redux
Then I created a custom routeReducer as below:
I modified rootReducer.js as below:
And In main.js I changed the selectLocationState as below:
And Its working absolutely fine with immutableJS reducers.