redux and thunk, no API yet

This commit is contained in:
2024-04-24 15:21:01 -04:00
parent e2c9faa01e
commit 5db0d0afc1
11 changed files with 176 additions and 36 deletions

View File

@ -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);