I'm rendering values from an array of objects . I made a counter to count how many objects in array to loop all of them , but it only loops once. I know after I'm returning , function breaks, but I don't know how to do it other way. Check my sandbox, I recreated my problem https://codesandbox.io/s/goofy-easley-w5rrg
const displayData=(data)=>{
let counter = 0
for (let i = 0; i < data.length; i++) {
if (counter <= data.length+1) {
counter++
return Object.keys(data[i]).map((value,ids)=>{
return <span key={ids}>{data[i][value]} </span>
})
}
}
}