TanStackT
TanStack3y ago
14 replies
primary-violet

Return latest result from query key?

My end goal is to have a query that sets a current search term, with a query key of ["query", searchTerm], and another query that returns the latest "query" search term, so the latest query of key ["query", *]. I'd like to do this so that I can keep a "history" of previous search terms, since it's computationally expensive to run them. I know it's not a very good explanation, but I hope it makes sense! The tl;dr is that I need a component "subscribe" to all queries that start with "query" but only return the newest one.
Was this page helpful?