August 2017
Beginner
374 pages
10h 41m
English
Now, all that is left to do is combining these two reducers together to handle the whole state and all actions of the application:
function appReducer (state = {}, action) { return { posts: postsReducer(state.posts, action), filter: filterReducer(state.filter, action), }}
The default state for our app is an empty object, {}. We create the state object by passing the substates and actions down to our other reducers. On initialization, these reducers get passed undefined, because state.posts and state.filter do not exist, yet. As a result, the default state defined in the subreducers will be used.
Read now
Unlock full access