-
Notifications
You must be signed in to change notification settings - Fork 2
/
table.tsx
37 lines (32 loc) · 1.02 KB
/
table.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use client";
import { UserTable } from "@examples/lib/src/components/UserTable";
import {
useUserData,
userColumns,
} from "@examples/lib/src/components/userData";
import {
getCoreRowModel,
getFilteredRowModel,
getPaginationRowModel,
getSortedRowModel,
useReactTable,
} from "@tanstack/react-table";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useTableSearchParams } from "tanstack-table-search-params";
export const BasicTable = () => {
const data = useUserData();
const replace = useRouter().replace;
const query = useSearchParams();
const pathname = usePathname();
const stateAndOnChanges = useTableSearchParams({ replace, query, pathname });
const table = useReactTable({
data,
columns: userColumns,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getPaginationRowModel: getPaginationRowModel(),
...stateAndOnChanges,
});
return <UserTable table={table} />;
};