Skip to content
Discussion options

You must be logged in to vote

it's stale because queries that have no data are always considered stale.

The problem in your situation is automatic property tracking. We only track properties that you are using, which is a render optimization. In your example, you're only using the refetch value returned from useQuery and nothing else, so your hook doesn't re-render when new data / error comes in.

You can set notifyOnChangeProps: 'all' for your hook (or for the queryClient that you use for testing) to work around this.

But generally: This is one of the reasons why I'm not a fan of testing hooks in isolation. Rather test the component that is using the hook and you will test what your users are seeing.

here's a working …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RoryMacGregor88
Comment options

Answer selected by RoryMacGregor88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants