Create Multiple Redux Actions with an Action Map in redux-actions

Share this video with your friends

Send Tweet

In this lesson, we’ll use the plural createActions function and an action map to create multiple action creators with a single utility from redux actions.

Joseph Groves
Joseph Groves
~ 6 years ago

Excellent class, one question out of the topic, What is the font and theme that you are using?

Paul Kim
Paul Kim
~ 6 years ago

The multi-line cursor is very cool!

Chester Rivas
Chester Rivas
~ 6 years ago

The font is called "Operator Mono", I'm not sure about the theme.

Chester Rivas
Chester Rivas
~ 6 years ago

I'm trying to implement this is a proof of concept. It works fine, the only issue is that if I try to namespace an action ie:

const SET_LIST = 'app/queries/SET_LIST';

the createActions method will not properly camelcase the action. Is there a way around that? I've been Googling but I haven't come across a solution yet.

Andy Van Slaars
Andy Van Slaars(instructor)
~ 6 years ago

Chester,

You could nest the keys in your actionMap to get to your desired types.

From the docs:

If actionMap has a recursive structure, its leaves are used as payload and meta creators, and the action type for each leaf is the combined path to that leaf:

https://redux-actions.js.org/api/createaction#createactionsactionmap

Hope this helps!

Yilu
Yilu
~ 6 years ago

tgdg