React Redux Actions
In this tutorial, we will learn to define various Redux actions and implement the action creators to dispatch the actions to the Redux store. At the end of this tutorial, you will be able to:
- Define Redux actions and implement the action creators
- Dispatch actions from the action creators to update the system state in the Redux store
Creating Actions
- In the redux folder create a new file named ActionTypes.js and add the following to it:
- Then, create a file named ActionCreators.js and add the following to it:
- Next, update comments.js to initiate action when the action is dispatched by the ActionCreator as follows:
- Now update MainComponent.js to make the action available for use within the DishdetailComponent as follows:
- Finally, update DishdetailComponent.js as follows to initiate the action upon the user submitting the comment form:
(source: Front-End Web Development with React on Coursera)