feat: add error handling to onCount function and ensure local count is set correctly

This commit is contained in:
faisolavolut 2025-02-20 13:45:10 +07:00
parent 09fc4af459
commit d7682b47ba
1 changed files with 10 additions and 5 deletions

View File

@ -238,11 +238,13 @@ export const TableList: React.FC<any> = ({
{"Loading..."}
</>
);
if (typeof onCount === "function") {
const res = await onCount();
local.count = res;
local.render();
}
try {
if (typeof onCount === "function") {
const res = await onCount();
local.count = res;
local.render();
}
} catch (ex) {}
if (mode === "form") {
local.data = fm.data?.[name] || [];
cloneListFM(fm.data?.[name] || []);
@ -264,6 +266,9 @@ export const TableList: React.FC<any> = ({
if (!autoPagination) {
res = paginateArray(res, take, 1);
}
if (!local.count) {
local.count = res?.length;
}
local.data = res;
if (mode === "form") cloneListFM(res);
local.render();