Previous, we do composition with objects:
const todoApp = (state = {}, action) => { return { todos: todos( state.todos, action ), visibilityFilter: visibilityFilter( state.visibilityFilter, action ) }; };
Since it is common options in Redux, there is a function call ‘combineReducers‘:
const {combineReducers} = Redux; combineReducers({ todos, //ES6 shortcut syntax visibilityFilter });
时间: 2024-10-27 19:10:30