My application is crashing because of the second part of this render statement c is not defined (after the comma in return).
I want to render not only this element as the CategoryTreeFork component, but also render it's children along-side it as the same component.
Am I making a mistake in trying to access that variable?
<div className="categories-narabikae">
<p>Displayed Categories </p>
{
filterActiveCategories(categories).map((c, idx) =>
<CategoryTreeFork
key={idx}
parentCat={null}
thisCat={c}
level={1}
dropEvent={this.handleDropEvent}
/>
,
c.children
? c.children.map( (c2, idx) =>
<CategoryTreeFork
key={idx}
parentCat={c}
thisCat={c2}
level={2}
dropEvent={this.handleDropEvent}
/>
)
: null
)
}
</div>
Edit: it looks like during the first render of the page the array that I am mapping is empty (has not yet retrieved categories from API) -- would this possible trigger the error?
CategoryForkbe called recursively, each time passing new children as prop.return (val1, val2)in ES6. I have to avoid recursive components on this one so I think I will have to prepare the data in my array with additional attributes to get the desired effect with sibling components.I thought you could do return (val1, val2) in ES6You can, but not in this way with React. See the comma operator. (discards all but the last item)