Adding Payloads to Actions

Learn how to add payloads to different Redux actions.

We'll cover the following

It’s common for actions to contain additional information about what happened. For example, a user might type a query into a search field and click the “Submit” button. We would want to know what they searched for in addition to knowing they clicked the “Submit” button.

Adding the payload property

There are no hard and fast rules for structuring an action—other than Redux’s insistence that we include a type property. But it’s a good practice to follow some kind of standard like Flux standard actionhttps://github.com/redux-utilities/flux-standard-action, which advises us to put any additional information needed in a payload property.

Following this convention, our CounterAction might look similar to as shown below:

Get hands-on with 1400+ tech skills courses.