Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
- */
Add Comment
Please, Sign In to add comment