Defining actions and action creators

Reducers accept an action object that describes the action that is going to be performed and decides how to transform the state based on this action object.

Actions are just plain objects and they have only one required property that needs to be present, the action-type. For instance:

const action = { 
    type: 'INCREMENT_COUNTER', 
} 

We can also provide additional properties as well. For instance:

const action = { 
    type: 'INCREMENT_COUNTER', 
    incrementBy: 2, 
} 

Actions creators are just functions that return actions, for instance:

const increment = (incrementBy) => ({ 
    type: 'INCREMENT_COUNTER', 
    incrementBy, 
}) 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.204.247