javascript - How can I combine child nodes with JSX? -
i want build ul list li elements, li elements come different sources, can't in 1 statement. appears jsx can't handle set of child elements, gives me syntax error:
var items = <li>s</li> <li>s</li> <li>s</li>;
ideally want like:
var items1 = <li>s</li> <li>s</li> <li>s</li>; var items2 = <li>s</li> <li>s</li> <li>s</li>; var list = <ul>{items1}{items2}</ul>;
is there way achieve this?
jsx desugars straightforwardly javascript syntax can mix freely.
/** @jsx react.dom */ var items1 = [ <li>s</li>, var items1 = [ react.dom.li({}, "s"), <li>s</li>, react.dom.li({}, "s"), <li>s</li> ]; react.dom.li({}, "s") ]; var items2 = [ <li>s</li>, var items2 = [ react.dom.li({}, "s"), <li>s</li>, react.dom.li({}, "s"), <li>s</li> ]; react.dom.li({}, "s") ]; var list = <ul>{items1+items2}</ul>; var list = react.dom.ul({}, items1+items2);
Comments
Post a Comment