T
TanStack4w ago
absent-sapphire

Why does `useReactTable` need `columns` and `data` to be mutable?

I was trying to use tanstack table for the first time, and my API is typed as deeply readonly, and I'm surprised tanstack table seems to require "write permissions" on the data and columns arrays
const { data } = useQuery(...)
// ^? readonly Foo[]
useReactTable({
data,
//^^^^ The type readonly Foo[] is not assignable to the mutable type Foo[]
})
const { data } = useQuery(...)
// ^? readonly Foo[]
useReactTable({
data,
//^^^^ The type readonly Foo[] is not assignable to the mutable type Foo[]
})
I know I often get annoyed myself when I have to write readonly or ReadonlyArray<> everywhere in my types, so I'm hoping this is just the reason why it's "requesting write permissions", but maybe it's actually mutating the arrays?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?