Skip to content

Instantly share code, notes, and snippets.

@akellbl4
Created October 31, 2019 08:39
Show Gist options
  • Save akellbl4/cc486e24ec21151fa576785c3406919e to your computer and use it in GitHub Desktop.
Save akellbl4/cc486e24ec21151fa576785c3406919e to your computer and use it in GitHub Desktop.
Redux Action Creator
export type Action<P, T = string> = { type: T; payload: P | undefined }
export function createAction<T, P = any>(type: T) {
const actionCreator = (payload: P | undefined): Action<P, T> => ({ type, payload })
actionCreator.type = type
return actionCreator
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment