TanStackT
TanStack3y ago
1 reply
primary-violet

Accessing previously paginated data within react query

Hey guys, i'm using React query to power a paginated table, the rows of the table are selectable. The table lib i'm using keeps an array in state of the selectedRowKeys. The issue i'm having is the react-query data at any one time is just that viewable page, so when I map through the array of selectedRowKeys to build the array of the full table rows with all the data, only a subset is there and I get an incomplete array.

What's the best way to handle this (what I can imagine is a common issue? ) I could onChange push them on when I have those rows loaded in the hook, but then i'm having to manage 2 bits of state, and i'd rather have one derive the other. Any suggestions appreciated.
Was this page helpful?