skip to Main Content

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


  1. Probably the problem in this line:

    getRowId={(row) => row._id}
    

    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.

    Login or Signup to reply.
  2. Can you try rows?.map , as on first render the row might be null and leter get its value.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search