¡GoConqr estrena diseño! Cuéntanos qué te parece.

Módulo 6 de 18 · Multimedia

Create actions

Kostas Diakogiannis

Create actions

Let's create some actions

Let's create some actions. Until now we now, that there are two types of operations we would like to happen. The deposit action, and the withdraw action.

Actions are actually objects that are returned from functions. These functions can be called whenever we want and we can associate them with an event (click of a mouse etc). But for now as you can see above they return always an object with a type property that accepts a string, and additional properties that represent values of data that will be passed to the reducer.

In our case, think that the type property is a mandatory property because the reducer (the father or the manager) must somehow recognize which type of operation it must execute. This piece of info it is stored in a form of a string inside the type property of an action object. The other properties are optional, but in this case we would like also to pass not only the name of the action that should be dispatched but also the amount of money that should be either deducted from the balance (state) or added there.

Instrucciones

Para avanzar en el curso, envía un intento de este test. Puedes enviarlo después de la última pregunta.

Ir al módulo elegido

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?