T
tRPC

Caching(?) previous data until query returns new data

Caching(?) previous data until query returns new data

ZZen5/10/2023
when I update my useQuery inputs with new filters it instantly sets the data to undefined while the query isLoading. Is there a way to keep the previous data there until the new data returns from the server? Currently there's big flashes in the UI between applications of the filters, as my data length drops to effectively zero then bounced back up again when the new data loads
ZZen5/10/2023
nevermind, found it. There's a flag you can put on the query keepPreviousData:true - https://tanstack.com/query/v4/docs/react/guides/paginated-queries#better-paginated-queries-with-keeppreviousdata

Looking for more? Join the community!

T
tRPC

Caching(?) previous data until query returns new data

Join Server