I'm really struggling to understand what's wrong with the syntax in the following react function
const listItem = (parentId) => {
var childCategories = categories.filter(category => category.ParentId === parentId)
return (
childCategories.map(category => (
<ListItem key={category.Id} button>
<ListItemText primary={category.Name} />
</ListItem>
listItem(category.Id) //// it doesn't like this line
))
)
}
if I take out the line with the comment "//// it doesn't like this line" the function works except of course there is no recursion. I've tried all different combinations of {} and() e.g. {listItem(category.Id)} but it still doesn't work. Any idea what's wrong with the syntax.