Created
October 31, 2019 08:39
-
-
Save akellbl4/cc486e24ec21151fa576785c3406919e to your computer and use it in GitHub Desktop.
Redux Action Creator
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
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