The issue is that the variable is having the value when I console.log but it is not rendering in the page. The loop print only the first data and other data is not printed.
const langData = [
{
name: "Front-End",
children: [
{
name: "HTML"
},
{
name: "CSS"
},
{
name: "JS"
}
]
}
];
const renderName = ({ name, children }) => {
console.log(name);
return (
<>
<p>{name}</p>
{children && children.forEach(newData => renderName(newData))}
</>
);
};
const App = () => {
return <div className="App">{renderName(langData[0])}</div>;
};
Eg: Front-End will be on the page. Other data such as HTML, CSS, JS not showing in the page. But these variables are in the console.log. Not sure I miss to return any value.
Codesandbox link: https://codesandbox.io/s/reverent-ardinghelli-6snby?fontsize=14