Created
September 8, 2017 16:37
-
-
Save 0x6a68/89465f39a4ff40be568d1bb0ea04b18b to your computer and use it in GitHub Desktop.
react typescript `asList`
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 * 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