Skip to content

Instantly share code, notes, and snippets.

@carlrip
Created August 25, 2019 05:08
Show Gist options
  • Save carlrip/b21b4a05c5b4a6ea08ab45c721b0fcc7 to your computer and use it in GitHub Desktop.
Save carlrip/b21b4a05c5b4a6ea08ab45c721b0fcc7 to your computer and use it in GitHub Desktop.
Simple List component
interface Props {
data: string[];
renderItem?: (item: string) => JSX.Element;
renderHeader?: () => JSX.Element;
}
export const List: FC<Props> = ({ data, renderItem, renderHeader }) => (
<div className="list">
<div className="list-header">{renderHeader && renderHeader()}</div>
<ul>
{data.map(item => (
<li key={item}>{renderItem ? renderItem(item) : item}</li>
))}
</ul>
</div>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment