mapDispatchToProps Lab
Objectives
Use the React Redux library to connect the store to the React application. Utilize the Provider component, and the connect() function in the process. Make sure to also implement mapDispatchToProps().
Overview
In this application we will be building an application to keep track of our favorite restaurants. We will keep our React application separated from our Redux application by using the Provider component and the connect() function. We will not include a reference to the store in any component except for the Provider.
Instructions
Redux is already set up through index.js
and the reducer manageRestaurants
.
Write a mapDispatchToProps() function that allows us to pass dispatched
actions as props.
Remember that mapDispatchToProps() is provided dispatch
as an argument
(passed in by connect
when called), so we can wrap an imported action with
dispatch
within mapDispatchToProps(). Don't forget that the action
provided in actions/restaurants.js
is a function that must be called in
order to return the action object.