Introducing Action Creators

This lesson will show you a simple technique for quickly accessing your desired action: An Action Creator!

Take a look at the actions we created in the previous lesson. You’ll notice that we are repeating a few things.

For one, they all have the same type field. If we had to dispatch these actions in multiple places, we’ll have to duplicate them all over the place. That’s not so good. Especially because it’s a good idea to keep your code DRY.

Can we do something about this? Sure!

Welcome, Action Creators.

Redux has all these fancy names, eh? Reducers, Actions, and now, Action Creators :)

Let me explain what those are.

Action Creators are simply functions that help you create actions. That’s all. They are functions that return action objects.

In our particular example, we could create a function that will take in a text parameter and return an action, like this:

Get hands-on with 1200+ tech skills courses.