Created
April 10, 2019 13:22
-
-
Save StevenConradEllis/adbf886033a885dd68d6f5b0d3fa341c to your computer and use it in GitHub Desktop.
Example of Redux 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
import * as branches from './actions'; | |
import { ActionType, getType } from 'typesafe-actions'; | |
import { BranchState } from "./types"; | |
const defaultState: BranchState = { | |
branches: [] | |
} | |
export type BranchAction = ActionType<typeof branches>; | |
export default (state = defaultState, action: BranchAction): BranchState => { | |
switch (action.type) { | |
case getType(branches.fetchBranches.success): | |
return { | |
...state, | |
branches: action.payload | |
} | |
default: | |
return state; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment