August 2017
Beginner
374 pages
10h 41m
English
As we have learned in Chapter 1, Why Redux? reducers use the type property to check which action happened. That works fine, but there is a little problem with the value—it's a string. With string values, it is very easy to make mistakes, such as typos. Furthermore, we will need to know all possible string values (action types), which means that we need to consult the documentation or reducer source files—that's not good.
In Redux projects, we usually store the type property of the action in a constant, as follows:
const CREATE_POST = 'CREATE_POST'const createPost = { type: CREATE_POST, user: 'dan', text: 'New post' }console.log(createPost)
The first line defines what is called an action type in the Redux world. We ...
Read now
Unlock full access