In the previous section, we covered how to change state in the old way and how to do it in the new Redux-like way. The reducers are nothing more than pure functions; pure in the sense that they don't mutate but produce a new state. A reducer needs an action to work though. Let's deepen our knowledge on Reducers and Actions. Let's create an action meant to add things to a list and a reducer that goes with it:
// core-concepts/jedilist-reducer.jslet actionLuke = { type: "ADD_ITEM", payload: { name: "Luke" } };let actionVader = { type: "ADD_ITEM", payload: "Vader" }; function jediListReducer(state = [], action) { switch(action.type) { case "ADD_ITEM": return [... state, action.payload]; default: return state; }}let state = jediListReducer([], ...