Skip to content

Instantly share code, notes, and snippets.

Last active Jan 25, 2017
What would you like to do?
React-redux action creator
// Example 1 with no payload
export function incrementCounter(){
return {type:"INCREMENT_COUNTER"};
The action is only the object that is being return
that is: {type:"INCREMENT_COUNTER"}
Rest of the function is called Action creator - which creates the action
// Example 2: action with addistional data (payload)
export function incrementCounterByIndex(index){
return {type:"INCREMENT_COUNTER", payload:{index}};
In this example we are transferring a payload object, with
a property of index.
Remember we are using ES6 convention becuase of which we need not
to write as index: index , LHS=RHS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment