I am making sure that the rows
is filled and defined before using, but why is the error coming, i am not able to understand , it is been a week now , i am stuck here,
How to solve this please !
return isSmallScreen ? (
<div>
<List sx={{ width: "100%" }}>
{rows &&
rows.map((row) => (
<ListItem>
<ListItemText primary={row.name}></ListItemText>
</ListItem>
))}
</List>
</div>
) : (
<DataGrid
className=""
getRowId={(row) => row._id}
rows={rows}
columns={columns}
pageSize={30}
rowsPerPageOptions={[30]}
disableSelectionOnClick
experimentalFeatures={{ newEditingApi: true }}
autoHeight={true}
autoPageSize={true}
selectionModel={selectedRows}
onSelectionModelChange={(ids) => {
setSelectedRows(ids);
}}
/>
);
2
Answers
Probably the problem in this line:
You are describe the function, but row isn’t defined yet, so row._id will throw the error.
If it doesn’t help, please provide us a little bit more information to reproduce the problem.
Can you try rows?.map , as on first render the row might be null and leter get its value.