I am using React and Material UI for this project, and need to render a grid where the rows are from an array of data and the columns contain specific information like this:
<Grid container>
{myData.map((record) => (
<>
<Grid item>{record.field1}</Grid>
<Grid item>{record.field2}</Grid>
<Grid item>{record.field3}</Grid>
</>
)}
</Grid>
This of course results in the React warning about items in the list not having unique keys.
The problem is that < key={index}> is not valid in React, and replacing <> with an actual tag like <div> for example messes up the grid; which expects grid items to be directly contained within the grid container.
Is there any way to work around this problem?