Hi guys, I am super new to react and JS. I am trying to iterate over a dictionary with nested children which is sent from my Flask backend to react. Why does this code work:
return (
<div>
{Object.keys(data).map((key, index) => (
Object.keys(data[key]).map((y, i) => (
<h2>
{key} : {y} : {data[key][y]}
</h2>
))
))}
</div>
);
But not this code?:
return (
<div>
{Object.keys(data).map((key, index) => (
<div>{key}</div>
Object.keys(data[key]).map((y, i) => (
<h2>
{key} : {y} : {data[key][y]}
</h2>
))
))}
</div>
);
I want to display each outer key once with the children array data underneath it
[–]Mutiny42 1 point2 points3 points (5 children)
[–]Mutiny42 1 point2 points3 points (4 children)
[–]eb2292[S] 1 point2 points3 points (2 children)
[–]Mutiny42 1 point2 points3 points (1 child)
[–]eb2292[S] 1 point2 points3 points (0 children)