Create Html Structure Which Will Allow Only 3 Div Elements In Each Li. In React + Underscore.js
This is bit copy of How to create html structure which will allow only 3 div elements in each li. In React + underscore.js Actually i am facing issue while iterating array in li. I
Solution 1:
const Com = () => {
var xyz = [{'name': ['abc','xyz','test','test1','test2','test3','test4'] }];
return (
<ul>
{_.map(_.chunk(xyz[0].name, 3), (innerItem, i) => (
<li key={i}>
{_.map(innerItem, (name, j) => (<div key={j}><span>{name}</span></div>))}
</li>
))}
</ul>
);
}
ReactDOM.render(<Com />, document.getElementById("container"));
An example bin an be found here: http://jsbin.com/menidu/4/edit?js,output
Solution 2:
something like this would be required
return (
<ul>{chunkedLists.map(group => <li>{group.map(i => <div><span>{i}</span></div>)}</ul>)}
)
Post a Comment for "Create Html Structure Which Will Allow Only 3 Div Elements In Each Li. In React + Underscore.js"