0

I don't know if the creators of react-query have updated the library but , I can't seem to be able to access setQueryData from queryCache nor can I import queryCache from react-query .
I looked at the docs and it looks like its queryCache that is now importable from react-query , and this is how its used :

import {QueryCache,useMutation} from  "react-query" 

const queryCache= new QueryCache({
    onError:err=>console.log(err)
})

//but now thsi only has these 4 functions 
//queryCache.find
//queryCache.findAll
//queryCache.subscribe
//queryCache.clear

is these something I'm missing here because I've been following some tutorials and they're using setQueryData

1 Answer 1

1
  • you've probably migrated to v3, which is a major version change
  • in v3, you'll interact with the QueryCache via the QueryClient
  • There is no global cache to import anymore - the recommended way is to call the useQueryClient hook, or to export the client that you created yourselves.

Please have a look at the extensive migration guide: https://react-query.tanstack.com/guides/migrating-to-react-query-3

all the examples and docs also use v3, so this should get you going.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks a lot I figured it was a major version change but had no idea how to migrate ,they probably should include a versions dropdown in their docs site's navbar
there is a link to the v2 docs directly on the starting page, it links to: react-query-v2.tanstack.com/docs/overview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.