I'm a bit confused by the code below.
The itmLoop
function seems to work fine when placed directly in the return section, but nothing is output when it's called as shown below?
I'll eventually need to make it recursive, so I have to keep it as an external function.
Could someone help me figure out what I'm doing wrong?
Thanks a lot!
const Output = () => {
const items = [
{title:"lvl1-1",
children:[
{title:"lvl2-1"},
{title:"lvl2-2"}
]},
{title:"lvl1-2"},
{title:"lvl1-3"}
];
function itmLoop(arr=[]){
arr.map((e)=>{
return (<span>{e.title}</span>)
})
}
return ( { itmLoop(itms) } )
}
export default Output