T
TanStack3y ago
optimistic-gold

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
other-emerald
other-emerald3y ago
If the exported function is called from a component that is a descendant of QueryClientProvider, that should work, yes.
optimistic-gold
optimistic-goldOP3y ago
Got it, thank you.
absent-sapphire
absent-sapphire5mo 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
rising-crimson
rising-crimson5mo ago
then you have likely bundled two versions of react-query

Did you find this page helpful?