feat(Table): reset to the first page if there is less data to show

This commit is contained in:
xzdry 2022-10-17 22:47:55 +08:00
parent 0fb888fff9
commit 9ee265882d

View File

@ -281,6 +281,20 @@ export const Table = implementRuntimeComponent({
});
}, [currentPageData, mergeState, rowKey]);
// If there is less data to display than the current page, reset to the first page
useEffect(() => {
if (useCustomPagination) return;
if (currentPageData.length <= Number(pageSize) * (currentPage - 1)) {
setCurrentPage(1);
}
}, [
currentPage,
currentPageData.length,
pageSize,
setCurrentPage,
useCustomPagination,
]);
useEffect(() => {
setColumns(
cProps.columns!.map((column, i) => {