I was trying to get the object key of the array to display as the header of table but failed with using map in react. by using console.log, I was able to see it return the correct value it return blank on the HTML.
Here is my code
<tr>
{fileList.forEach((titleList) => {
const title = [];
title.push(Object.keys(titleList))
// console.log(title)
title.map((item, key) => {
// console.log(item)
return <th key={key} scope="col">{item}</th>
})
})
}
</tr>
The json data was from here: https://jsonplaceholder.typicode.com/posts/1/comments Here is my full project code if you willing to check: https://codesandbox.io/s/dry-wave-gu0ns?file=/src/listPage/ListPage.js
Thanks!