Created
May 28, 2021 12:26
-
-
Save mushfiqweb/4d525129429e3fafc72ca4e67e32443b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| users: [{ id: "1231", username: "Dale" }, { id: "1235", username: "Sarah"}] | |
| } | |
| { | |
| type: "ADD_USER", | |
| payload: { user: { id: "5123", username: "Kyle" } } | |
| } | |
| const userReducer = (state, action) => { | |
| switch (action.type) { | |
| case "ADD_USER": | |
| return { ...state, users: [...state.users, action.payload.user ]} | |
| default: | |
| return state; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment