I am trying to iterate the Mui component MenuItem by using forEach loop but I am getting Type 'void' is not assignable to type 'ReactNode' error. Here is my code snippet-
<TableCell>
<Typography>expiry</Typography>
<Select variant="outlined" sx={{ width: '100%', height: 35, borderRadius: 2 }}>
{ groupData.forEach((option) => (
<MenuItem key={option.expiry} value={option.expiry}>
{option.expiry}
</MenuItem>
))}
</Select>
</TableCell>
Thanks in Advance
.mapinstead of.forEach?.forEachdoesn't return anything. If you want to create an array of<MenuItem>s, you need to use.map.