Skip to content

Instantly share code, notes, and snippets.

@0x6a68
Created September 8, 2017 16:37
Show Gist options
  • Save 0x6a68/89465f39a4ff40be568d1bb0ea04b18b to your computer and use it in GitHub Desktop.
Save 0x6a68/89465f39a4ff40be568d1bb0ea04b18b to your computer and use it in GitHub Desktop.
react typescript `asList`
import * as React from 'react';
function asList<P>(ItemComponent: React.ComponentClass<P> | React.StatelessComponent<P>) {
return function List({ items }: { items: P[] }) {
return (
<ol>
{items.map((item, idx) =>
<li key={idx}>
<ItemComponent {...item} />
</li>)
}
</ol>
);
};
}
export default asList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment