QueryObserver

QueryObserver

The QueryObserver can be used to observe and switch between queries.

js
const observer = new QueryObserver(queryClient, { queryKey: 'posts' })
const unsubscribe = observer.subscribe(result => {
console.log(result)
unsubscribe()
})

Options

The options for the QueryObserver are exactly the same as those of useQuery.

Want to Skip the Docs?

Fast track your learning and
take the offical React Query course ↗️

Subscribe to Bytes

Your weekly dose of JavaScript news. Delivered every Monday to over 100,000 devs, for free.

Bytes

No spam. Unsubscribe at any time.