1. 9
    Make Dispatching Redux Actions More Reliable With Action Creators
    3m 16s

Make Dispatching Redux Actions More Reliable With Action Creators

Andy Van Slaars
InstructorAndy Van Slaars

Share this video with your friends

Send Tweet

Dispatching actions is how our application sends information to Redux in order to update state. While we could build our action objects inline and use strings for action names, this can be tedious and error prone. In this lesson, we’ll see how the use of constants and action creator functions will make dispatching actions easier and more reliable.

Andrew Fritz
Andrew Fritz
~ 4 years ago

This also feels out of order

Antonio Santiago
Antonio Santiago
~ a year ago

hello @Andy Van Slaars, in a large application, would you recommend to have a central directory/folder of "action dispatchers" functions that take a payload parameter and automatically dispatch the actions, or rather, functions like the one you created here, that only create the action type and then those are taken as param to then dispatch somewhere else? approach 1: -- redux/dispatchers --- todo ---- export const updateCurrent = (val) => store.dispatch({type: CURRENT_UPDATE, payload: val}); and in some other file i just call my dispatcher updateCurrent()

approach 2: -- redux/reducers --- todo.js ---- export const updateCurrent = (val) => ({type: CURRENT_UPDATE, payload: val}); and in some other file i do store.dispatch(updateCurrent(val))

thanks!