Guest User

Untitled

a guest
May 26th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. const ListComponentMap = L => C => M => Ch => (<div>{
  2. ( typeof L === 'number' ?
  3. ((L) => {
  4. let arr = new Array(L);
  5. for (let k = 0; k < arr.length; k++) (arr[k] = k + 1);
  6. return arr; })(L)
  7. : L )
  8. .map((i, n) =>
  9. <C key={n} {...typeof M === 'function' ? M(i, n) : M }>
  10. {typeof Ch === 'function' ? Ch(i, n) : Ch}
  11. </C>)
  12. } </div>);
  13.  
  14. /*
  15. ACCEPTED VALUES:
  16. {
  17. ListComponentMap
  18. (fruits) // array list
  19. (HH) // react component
  20. ( (item, index) => ({ name: item }) ) // props from function
  21. ((i, n) => <H name={n} />) // children from function
  22. }
  23. {
  24. ListComponentMap
  25. (number) // number
  26. (HH) // react component
  27. ( { name: "item" } ) // props from object
  28. (<H name="josh"/>) // children from component
  29. }
  30. */
Add Comment
Please, Sign In to add comment