April 2017
Intermediate to advanced
414 pages
8h 14m
English
Actions are simple objects containing information that sends data from your app over to the app's store. All the logic that your app handles will pass through the action - your store never receives any data from sources that aren't actions.
An action requires a type property, which defines the type of user action that has occurred. Types of actions are represented in a stringified form. They can be hardcoded into the object itself or passed in as a constant. For example:
export function addTask(taskName) {
return {
type: 'ADD_TASK',
taskName: taskName
}
}
// With constants
const ADD_TASK = 'ADD_TASK';
export function addTask(taskName) {
return {
type: ADD_TASK,
taskName: taskName
}
}
These functions will be made available as props ...
Read now
Unlock full access