Skip to content

Instantly share code, notes, and snippets.

@flavioribeirojr
Created April 1, 2020 00:54
Show Gist options
  • Save flavioribeirojr/2a492567938ec67df207399013b81ce2 to your computer and use it in GitHub Desktop.
Save flavioribeirojr/2a492567938ec67df207399013b81ce2 to your computer and use it in GitHub Desktop.
Product List with Redux useSelector hook
import React from 'react';
import { useSelector } from 'react-redux';
function ProductList() {
const cart = useSelector(state => state.shop.cart);
return (
<div>
{
cart
.map(cartProduct => (
<h1 key={cartProduct.id}>
{ cartProduct.name }
</h1>
))
}
</div>
);
}
export default ProductList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment