Skip to content

Instantly share code, notes, and snippets.

@StevenConradEllis
Created April 10, 2019 13:22
Show Gist options
  • Save StevenConradEllis/adbf886033a885dd68d6f5b0d3fa341c to your computer and use it in GitHub Desktop.
Save StevenConradEllis/adbf886033a885dd68d6f5b0d3fa341c to your computer and use it in GitHub Desktop.
Example of Redux Reducer
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