I use the JavaScript Array map() Method to iterate an array and render HTML to my page. For example, I have ["Mike", "David", "Peter", Steve"] I can render them with Reach this way:
const RenderNames = () => {
let names = ["Mike", "David", "Peter", "Steve"];
const renderNames = (allNames) => {
return allNames.map( (name) => {
return <div> hello {name} </div>
}
}
return (
<div> {renderNames(names)} </div>
)
}
Ok, now I need to normalize that array to get an object like this: {"243fx": "Mike", "g3Frt": "David", "8879a": "Peter", "dkr45": "Steve"}
so how can I loop through this object and render all these elements?
const RenderNames = () => {
let names = {"243fx": "Mike", "g3Frt": "David", "8879a": "Peter", "dkr45": "Steve"};
const renderNames = (allNames) => {
????
????
}
return (
<div> {renderNames(names)} </div>
)
}