T
TanStack3y ago
rising-crimson

Creating NPM Package That Uses react-query

Hello. I have a question about building an NPM package that uses react-query. If my package exports a function that wraps a call to useQuery will that query have access to the application's QueryClientProvider? In this case the application would call the exported function.
4 Replies
ambitious-aqua
ambitious-aqua3y ago
If the exported function is called from a component that is a descendant of QueryClientProvider, that should work, yes.
rising-crimson
rising-crimsonOP3y ago
Got it, thank you.
stormy-gold
stormy-gold7mo ago
I'm trying this and it works when in the pnpm workspace, but not after the build with vite. Then I get an error about missing client provider
causal-orange
causal-orange7mo ago
then you have likely bundled two versions of react-query

Did you find this page helpful?