Array bounds checking

This commit is contained in:
Keith Stevens
2023-01-15 20:43:31 +09:00
parent a7748d0a3e
commit c36d5ed423
+26 -8
View File
@@ -62,17 +62,35 @@ const UsersCell = () => {
});
const toPreviousPage = () => {
setPagination({
cursor: users[0].display_name,
direction: "back",
});
if (users.length >= 0) {
setPagination({
cursor: users[0].display_name,
direction: "back",
});
} else {
toast({
title: "Can not paginate when no users are found",
status: "warning",
duration: 1000,
isClosable: true,
});
}
};
const toNextPage = () => {
setPagination({
cursor: users[users.length - 1].display_name,
direction: "forward",
});
if (users.length >= 0) {
setPagination({
cursor: users[users.length - 1].display_name,
direction: "forward",
});
} else {
toast({
title: "Can not paginate when no users are found",
status: "warning",
duration: 1000,
isClosable: true,
});
}
};
// Present users in a naive table.