Reputation: 704
var content = "";
for(var i=0;i<menuData.length;i++){
content += <li className={"accordion-menu-item "+showComponent} onClick={this.handleClick} id={menuTag}>
<div className={"menuLabel "+labelClassName}>{componentLabel}{manageActionLabel}</div>
{allowDropDownElement}
{this.createInnerComponent(allowDropDownFlag,innerComponents,showComponent)}
</li>
}
return <ul className="accordion-menu-wrapper">{content}</ul>
Above code is all put up in Reactjs. The above code is a code inside a function which is suppose to return the DOM string instead it return as [object object][object object][object object][object object]. Please help in solving this.
Upvotes: 1
Views: 4194
Reputation: 33618
Instead of using content as a string use an array.
var content = [];
for(var i=0;i<menuData.length;i++){
content.push(<li className={"accordion-menu-item "+showComponent} onClick={this.handleClick} id={menuTag}>
<div className={"menuLabel "+labelClassName}>{componentLabel}{manageActionLabel}</div>
{allowDropDownElement}
{this.createInnerComponent(allowDropDownFlag,innerComponents,showComponent)}
</li>);
}
return <ul className="accordion-menu-wrapper">{content}</ul>
Upvotes: 3