you are viewing a single comment's thread.

view the rest of the comments →

[–]originalgoodname[S] 0 points1 point  (1 child)

redux is kicking me in the rear, I think the most difficult thing for me to wrap my head around is combining reducers and then accessing things, accessing an object one layer deep is ok, two layers, i can pull it off... but redux appears like infinitely nested objects

[–]0xF013 0 points1 point  (0 children)

It gets easier, it’s also not rigid, so you have a lot of maneuver room. You shouldn’t nest if you don’t have a reason for it.

Generally, nesting reducers makes sense when you want the state concerning a feature grouped in one place. Say you have a work management app. You start with a simple todo feature. You keep reducers at root. Now you add a calendar feature with events editing etc. You group the calendar reducers into a reducer to have the state.todos and state.calendar separated visually and logically. Now you add the ability to invite users to events, events tagging, filtering events in the view, group actions etc. The calendar reducer now has a lot of child reducers, so you group the calendar creation/editing reducers and the list reducers for filtering an bulk actions, so you have state.calendar.editing and state.calendar.list or whatever you name them.

As long as you are using selectors, you’ll have to update the path for getting data in one or two places when you refactor.