Search⌘ K
AI Features

Adding Payloads to Actions

Understand how to add payload properties to Redux actions using TypeScript to carry extra data. Explore creating action creators and updating reducers to handle payloads, enhancing state management and type safety in React applications.

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 ...