Skip to content

Instantly share code, notes, and snippets.

@hartzis
Last active November 7, 2015 21:30
Show Gist options
  • Save hartzis/469416bd0ac506896e9c to your computer and use it in GitHub Desktop.
Save hartzis/469416bd0ac506896e9c to your computer and use it in GitHub Desktop.
Stateless functional components
export function CartItems({items, addToCart}) {
return (
<div>
<h3>Current Cart:</h3>
{items.map((item)=>CartItem(item, addToCart))}
</div>
)
}
export function CartItem({name}, addToCart) {
return (
<div>
{item.name}
<button onClick={()=>addToCart(item)}>Add to Cart</button>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment