I currently have a json file containing data for many people. It is in the following format:
'1': {
"name": Max
"age": 8
},
'2':
....
Next, I want to display each of these people as links in my function Foo(). I have written the function below.
import myData from './.../data.json'
function Foo (){
return (
<div>
<li>
<Link to={`${url}/1`>{myData[1].name}</Link>}
</li>
</div>
);
}
So far, I have done this manually. Now, what I want to do is somehow create a loop and create links for all of the people. I'm thinking of using 'map()' and 'Object.entries()' but I'm unsure of how and where to place them. Should I create a new function for them? I'm not sure....