Skip to content
Discussion options

You must be logged in to vote

I have seen some patterns lately where folks seem to use the Context API to pass data retrieved from React Query down to child components.
if there is any case whatsoever where using Context API along with React Query would make more sense?

I might be biased since I wrote the StackOverflow answer, so I usually prefer to call the custom useQuery hook whenever I need to. It does create more observers and timers, so if you have like 1000 of them, there have been reports of performance hits (e.g. on a 6x slowdown in chrome).

Putting data from react-query into the context api is not the worst idea though - it's just a decoupling of some sorts, just like prop drilling. consider:

- ParentA <--…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@shamilovtim
Comment options

@shamilovtim
Comment options

@TkDodo
Comment options

Answer selected by cmacdonnacha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants