Last active
May 21, 2018 19:00
-
-
Save xemasiv/ef32336553942662d3ee2300e81fe34b to your computer and use it in GitHub Desktop.
ListComponentMap
This file contains 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 ListComponentMap = L => C => M => Ch => (<div>{ | |
( typeof L === 'number' ? | |
((L) => { | |
let arr = new Array(L); | |
for (let k = 0; k < arr.length; k++) (arr[k] = k + 1); | |
return arr; })(L) | |
: L ) | |
.map((i, n) => | |
<C key={n} {...typeof M === 'function' ? M(i, n) : M }> | |
{typeof Ch === 'function' ? Ch(i, n) : Ch} | |
</C>) | |
} </div>); | |
/* | |
ACCEPTED VALUES: | |
{ | |
ListComponentMap | |
(fruits) // array list | |
(HH) // react component | |
( (item, index) => ({ name: item }) ) // props from function | |
((i, n) => <H name={n} />) // children from function | |
} | |
{ | |
ListComponentMap | |
(number) // number | |
(HH) // react component | |
( { name: "item" } ) // props from object | |
(<H name="josh"/>) // children from component | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment