Created
January 10, 2019 21:24
-
-
Save andrzejewsky/09c74df6863b8d320b674c8a7c87be10 to your computer and use it in GitHub Desktop.
Item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ListContext from "./context"; | |
import "./Item.css"; | |
const Item = ({ id, icon, className, info, children }) => ( | |
<ListContext.Consumer> | |
{value => ( | |
<button | |
className={["item", className].join(" ")} | |
key={id} | |
onClick={() => value.handleSelect(id)} | |
> | |
{icon} | |
<div className="item-name">{children}</div> | |
{info && <div className="item-info">{info}</div>} | |
</button> | |
)} | |
</ListContext.Consumer> | |
); | |
export default Item; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment