Skip to content

Instantly share code, notes, and snippets.

@andrzejewsky
Created January 10, 2019 21:24
Show Gist options
  • Save andrzejewsky/09c74df6863b8d320b674c8a7c87be10 to your computer and use it in GitHub Desktop.
Save andrzejewsky/09c74df6863b8d320b674c8a7c87be10 to your computer and use it in GitHub Desktop.
Item
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