I'm trying to create a simple NBA boxscore web app in React, but I am having trouble rendering the API data into separated tables for each game. I am trying to create separate tables with its own headers for each game based on the gameID value from the API. How can I achieve this?
import React, { Fragment } from 'react';
import ScoreCards from './ScoreCards';
const ScoreCardData = ({ gameStats }) => {
return(
<table>
<tbody>
<tr>
<td>gameID</td>
<td>Players</td>
<td>FGM/A FG%</td>
<td>FTM/A FT%</td>
<td>3PTM</td>
<td>PTS</td>
<td>REB</td>
<td>AST</td>
<td>ST</td>
<td>BLK</td>
<td>TO</td>
</tr>
{Object.keys(gameStats).map((gameData, i) => {
return(
<Fragment>
<tr key={i}>
<td>{gameStats[gameData].game.id}</td>
</tr>
</Fragment>
)
})
}
</tbody>
</table>
)
};
export default ScoreCardData;
Here is the code where I try to render the API data. I'm able to get a list of all the game ID's in one table, but I want to separate them according to gameID value so that I can display each table as a separate game. I also want to have the header row with all the stat names to be displayed for each table.
I'm basically just trying to create a simple NBA box score website, but I am having trouble actually rendering the data into a box score format. This is my first web application that I am creating, so I am very lost. Any help would be appreciated.
<td>tags with header names should be<th>tags because you are trying to render headers, not data. developer.mozilla.org/en-US/docs/Learn/HTML/Tables/…