redux and thunk, no API yet
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
import { useEffect } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { loadRestaurants } from '../store/restaurants/actions';
|
||||
|
||||
export default function RestaurantList({ loadRestaurants, restaurants })
|
||||
{
|
||||
export function RestaurantList({ loadRestaurants, restaurants }) {
|
||||
useEffect(() =>
|
||||
{
|
||||
loadRestaurants();
|
||||
@ -14,4 +15,11 @@ export default function RestaurantList({ loadRestaurants, restaurants })
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
restaurants: state.restaurants.records,
|
||||
});
|
||||
const mapDispatchToProps = {loadRestaurants};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(RestaurantList);
|
Reference in New Issue
Block a user