Replies: 5 comments 8 replies
-
The import { Table } from '@tanstack/react-table' |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Right now I try to refactor my row logic into a separate file and I get the same problem. I guess we need a proper Table type @tannerlinsley ? Or am I missing something here. I.e. this part in the example:
|
Beta Was this translation helpful? Give feedback.
-
let table = createTable<{
Row: Person
TableMeta: {
// We can tell our table about a custom "updateData" method we will provide it
updateData: (rowIndex: number, columnId: string, value: unknown) => void
}
}>()
// Get our table generics
type TableGenerics = typeof table.generics
// Use them in any type
function somethingWithTheTableInstance (instance: TableInstance<TableGenerics>) {
// ...
} |
Beta Was this translation helpful? Give feedback.
-
Turns out there shouldn't really be a need for a utility after all. All of the types for React Table rely on a single generic map. Either you know the generics ahead of time and want to enforce them: let table = createTable<{
Row: Person
TableMeta: {
// We can tell our table about a custom "updateData" method we will provide it
updateData: (rowIndex: number, columnId: string, value: unknown) => void
}
}>()
// Get our table generics
type TableGenerics = typeof table.generics
// Use them in any type
function somethingWithTheTableInstance (instance: TableInstance<TableGenerics>) {
// ...
} Or you don't know the generics and simply want to pass them through: export function somethingWithTheTableInstance <TGenerics extends AnyGenerics>(instance: TableInstance<TGenerics>) {
// ...
}
export function somethingWithARow <TGenerics extends AnyGenerics>(row: Row<TGenerics>) {
// ...
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As @tannerlinsley showed in #3818 you can access the Table generics via
table.generics
.However, now I try to refactor my columns into a separate file.
Is there a way to "create" the table type (like
type myTable = TableType<Person>
)?I try to accomplish sth. like this:
Right now, I always have to create my table instance in that function above.
Beta Was this translation helpful? Give feedback.
All reactions