Last active
January 20, 2019 16:47
-
-
Save joemaddalone/d0f422f57e02ccdfc5b485b7553e4dc3 to your computer and use it in GitHub Desktop.
Map Component
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
const Map = ({list, key, children}) => { | |
const child = React.Children.only(children); | |
const Item = child.type; | |
return list.map((item, index) => { | |
const keyed = Object.assign({key: item[key] || index}, item) | |
return React.createElement(Item, keyed); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment