Suggestion to warn against nested QueryClientProviders #2670
-
I just spent an hour debugging the react query devtools because not all of my queries would show up. It turned out to be one QueryClientProvider being inside another causing the issue. Unless there's a specific use case foe this, I suggest implementing a warning for this. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Not sure how this would technically be possible. It’s just react context under the hood, and nesting context providers is valid. Using a context just looks up the nearest provider. One use case would be to set different default options for a subtree as described here: https://tkdodo.eu/blog/testing-react-query#reactqueryconfigprovider |
Beta Was this translation helpful? Give feedback.
-
Hi @alvarlagerlof and @TkDodo I actually have a use case. I work on a project which uses I think it is also hard to tell if contexts are nested. However, would it be possible to maybe label the query clients? The default could be a uuid but the I believe it would really help with debugging. Any thoughts on this? |
Beta Was this translation helpful? Give feedback.
Not sure how this would technically be possible. It’s just react context under the hood, and nesting context providers is valid. Using a context just looks up the nearest provider.
One use case would be to set different default options for a subtree as described here: https://tkdodo.eu/blog/testing-react-query#reactqueryconfigprovider