Creating Actions
https://frontendmasters.com/courses/intermediate-react-v2/creating-actions/
Using the Reducers
Create the folder actionCreators
.
Some people prefer to use directly the action, Brian will use actionCretors.
// **** actionCreators/changeLocation.js ****
export default function changeLocation(location) {
return { type: "CHANGE_LOCATION", payload: location };
}
You can directly dispatch the actions ({ type: "CHANGE_LOCATION", payload: location }
), it's Ok too, the above function returns the action.
// **** actionCreators/changeTheme.js ****
export default function changeTheme(theme) {
return { type: "CHANGE_THEME", payload: theme };
}