Skip to content

Commit ff60476

Browse files
Skeleton paging when loading/fetching (#86)
This PR aims to fix the paging display when loading or fetching data
1 parent cf27c92 commit ff60476

2 files changed

Lines changed: 31 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- pagination skeleton on data loading and fetching.
13+
1014
## [5.13.1] - 2025-11-10
1115

1216
### Fixed

src/lib/ReactDataTable/ReactDataTable.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { useVirtualizer, Virtualizer } from "@tanstack/react-virtual";
1717
import { useRef } from "react";
1818
import { TableBody } from "./TableBody";
1919
import { useVirtualizationTableHeight } from "../hooks/useVirtualizationTableHeight";
20+
import Skeleton from "react-loading-skeleton";
2021

2122
interface TableInternalProps<TData, TFilter extends FilterModel = Record<string, never>> extends ReactDataTableProps<TData, TFilter> {
2223
virtualizer?: Virtualizer<HTMLDivElement, Element>;
@@ -272,6 +273,8 @@ const ReactDataTable = <TData, TFilter extends FilterModel = Record<string, neve
272273
totalRecords = table.getCoreRowModel().rows.length,
273274
dragAndDropOptions,
274275
pagingNavigationComponents,
276+
isLoading,
277+
isFetching,
275278
onPseudoHeightChange,
276279
} = props;
277280

@@ -326,24 +329,30 @@ const ReactDataTable = <TData, TFilter extends FilterModel = Record<string, neve
326329
</DndContext>
327330

328331
{showPaging && (
329-
<Paging
330-
currentItemsPerPage={pagination.pageSize}
331-
currentPage={pagination.pageIndex + 1}
332-
totalRecords={totalRecords}
333-
currentRecordCount={table.getRowModel().rows.length}
334-
setItemsPerPage={(x) => {
335-
table.setPageSize(x);
336-
}}
337-
setCurrentPage={(x) => table.setPageIndex(x - 1)}
338-
possiblePageItemCounts={pageSizes}
339-
translations={{
340-
itemsPerPageDropdown: reactDataTableTranslations.itemsPerPageDropdown,
341-
showedItemsText: reactDataTableTranslations.showedItemsText,
342-
}}
343-
pagingPossible={true}
344-
changePageSizePossible={!hidePageSizeChange}
345-
navigationComponents={pagingNavigationComponents}
346-
/>
332+
<>
333+
{isLoading || isFetching ? (
334+
<Skeleton count={1} height={20} />
335+
) : (
336+
<Paging
337+
currentItemsPerPage={pagination.pageSize}
338+
currentPage={pagination.pageIndex + 1}
339+
totalRecords={totalRecords}
340+
currentRecordCount={table.getRowModel().rows.length}
341+
setItemsPerPage={(x) => {
342+
table.setPageSize(x);
343+
}}
344+
setCurrentPage={(x) => table.setPageIndex(x - 1)}
345+
possiblePageItemCounts={pageSizes}
346+
translations={{
347+
itemsPerPageDropdown: reactDataTableTranslations.itemsPerPageDropdown,
348+
showedItemsText: reactDataTableTranslations.showedItemsText,
349+
}}
350+
pagingPossible={true}
351+
changePageSizePossible={!hidePageSizeChange}
352+
navigationComponents={pagingNavigationComponents}
353+
/>
354+
)}
355+
</>
347356
)}
348357
</>
349358
);

0 commit comments

Comments
 (0)