Created
March 6, 2019 11:38
-
-
Save tonkec/85fcfb711970fcbb83793c3db1fe8247 to your computer and use it in GitHub Desktop.
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
// action generator returns action object!! | |
const incrementCount = ( payload = {} ) => { | |
// if payload doesn't exist it defaults to {} | |
// calling property on undefined object will throw an error | |
// payload is an object passed to incrementCount | |
return { | |
// returns new action object! | |
type: 'INCREMENT', | |
incrementBy: typeof payload.incrementBy === "number" ? payload.incrementBy : 1 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment