Last active
April 2, 2022 12:38
-
-
Save antondevv/735380e4f139ee32532583c15eee0253 to your computer and use it in GitHub Desktop.
reducer
This file contains 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
const inititalState = { name: "User 1", age: 23 }; | |
const addUserReducer = (state = inititalState, action) => { | |
switch (action.type) { | |
case "CHANGEUSERNAME": { | |
return { ...state, name: action.payload }; | |
} | |
case "CHANGEAGE": { | |
return { ...state, age: action.payload }; | |
} | |
} | |
return state; | |
}; | |
export default addUserReducer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment