0

Really simple thing, if a URL parameter changes, previous data is no longer valid and should be cleared. However, when calling refetch from useEffect, useQuery doesn't do that.

Is there some parameter I should pass or something else?

3
  • If the parameters to useQuery changes you shouldn't need to call refetch at all. Batching/fetching/caching is normally handled automatically. Commented Dec 20, 2024 at 13:58
  • 1
    Maybe you are getting the URL parameters without passing them through useQuery? Commented Dec 20, 2024 at 13:59
  • @super Thank you! That's exactly what was going on. I've included URL parameter value as queryKey and now it works like you described. Commented Dec 30, 2024 at 7:51

1 Answer 1

0

You can achieved this by invalidating the query. From the official docs:

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

Comments

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.