) {
+}: DataTablePaginationProps) {
const searchParams = useSearchParams()
+ const { tableInstance: table } = useTableInstanceContext()
+
+ const page = searchParams.get("page")
+ const perPage = searchParams.get("per_page")
+
// Update pagination state when pagination params are changed
useEffect(() => {
- const page = searchParams.get("page")
- const perPage = searchParams.get("per_page")
-
table.setPageIndex(page ? Number(page) - 1 : 0)
table.setPageSize(perPage ? Number(perPage) : 10)
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [searchParams])
+ }, [page, perPage])
return (
@@ -51,6 +51,7 @@ export function DataTablePagination({
-
+
{table.getFilteredSelectedRowModel().rows.length > 0 && floatingBar}