1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Move useReactTable hook from Table to outer components

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-08-04 15:58:35 +03:00
parent cd2215097a
commit 69ad3974a8

View File

@ -5,31 +5,15 @@
import styles from "./react-table.module.scss";
import React from "react";
import {
flexRender,
useReactTable,
getSortedRowModel,
} from '@tanstack/react-table'
import type { TableOptions, Table, SortingState } from "@tanstack/react-table";
import { flexRender } from '@tanstack/react-table'
import type { Table } from "@tanstack/react-table";
interface TableProps<T> extends TableOptions<T> {
interface TableProps<T> {
table: Table<T>;
className?: string;
}
export function Table<Data>({ columns, data, getCoreRowModel, className }: TableProps<Data>) {
const [sorting, setSorting] = React.useState<SortingState>([])
const table = useReactTable({
data,
columns,
getCoreRowModel,
state: {
sorting,
},
onSortingChange: setSorting,
getSortedRowModel: getSortedRowModel(),
});
export function Table<Data>({ className, table }: TableProps<Data>) {
return (
<div className={className}>
<table>