feat: add error handling to onCount function and ensure local count is set correctly
This commit is contained in:
parent
09fc4af459
commit
d7682b47ba
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue