What is a Redux Action?

A syntactical view of a Redux Action and its components: Type and Payload

When you walk into a bank, the Cashier receives your action i.e intent for coming into the bank. In our previous example, we called this WITHDRAWAL_MONEY. The only way money leaves the bank Vault, is if you make your action i.e intent known to the Cashier.

Now, the same goes for the Redux Reducer. Unlike setState() in pure React, the only way you update the state of a Redux application, is if you make your intent known to the REDUCER.

But how? By dispatching actions!

In the real world, you know the exact action you want to perform. You could probably write that down in a slip and hand it over to the Cashier.

This works almost the same way with Redux. The only challenge is, how do you describe an action in a Redux app? Definitely not by speaking over the counter or writing it down in a slip.

Well, there’s good news.

An action is accurately described with a plain Javascript object. Nothing more.

There’s just one thing to be aware of. An action MUST have a type field. This field describes the intent of the action.

In the bank story, if we were to describe your action to the bank, it’d look like this:

Get hands-on with 1200+ tech skills courses.