标签:ssi red pre ons port ase die cat redux
1. split
const reducer = (state, action) => { switch (action.type) { case ‘ADD_RECIPE‘: return Object.assign( {}, state, { recipes: state.recipes.concat({name : action.name}) }); case ‘ADD_INGREDIENT‘: const myIngredients = { name : action.name, quantity: action.quantity, measure: action.measure, recipe: action.recipe }; return Object.assign( {}, state, { ingredients: state.ingredients.concat(myIngredients) }); } return state; }
1) recipeReducer
export const recipeReducer = (recipes, action) => { switch (action.type) { case ‘ADD_RECIPE‘: return recipes.concat({name : action.name}); } return recipes; }
标签:ssi red pre ons port ase die cat redux
原文地址:https://www.cnblogs.com/xiaobin-hlj80/p/9223914.html