adding nil check on rows before accessing length

This commit is contained in:
Carter 2025-04-10 12:24:07 -06:00
parent 4d5713a40c
commit c4c28a84d6

View file

@ -347,7 +347,7 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
</Card>
)
})}
{rows.length < 1 &&
{(rows && rows.length < 1) &&
(!isLoading ?
<Typography sx={{ textAlign: "center" }} color="textSecondary">
{ noDataMessage ? noDataMessage : "No data."}
@ -430,7 +430,7 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
</TableCell>
)
})
: rows.length > 0 &&
: (rows && rows.length > 0) &&
Object.keys(rows[0]).map((value, index) => {
return(
<TableCell key={"header-cell-"+index}>
@ -516,7 +516,7 @@ export default function ResponsiveTable<T extends Object>(props: Props<T>) {
)
})
}
{rows.length < 1 && !isLoading &&
{(rows && rows.length)< 1 && !isLoading &&
<TableRow>
<TableCell colSpan={6} sx={{textAlign: "center" }}>
<Typography variant="body2" color="textSecondary">