Skip to content

Instantly share code, notes, and snippets.

@antondevv
Last active April 2, 2022 12:35
Show Gist options
  • Save antondevv/d00499e64d60becac73fd27570dbcbd5 to your computer and use it in GitHub Desktop.
Save antondevv/d00499e64d60becac73fd27570dbcbd5 to your computer and use it in GitHub Desktop.
reducer
const inititalState = { name: "User 1", age: 23 };
const userReducer = (state = inititalState, action) => {
switch (action.type) {
case "CHANGEUSERNAME": {
return { ...state, name: action.payload };
}
}
return state;
};
export default userReducer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment