Skip to content

Reproduction steps for a react-query error that I encountered

Notifications You must be signed in to change notification settings

drywolf/react-query-error-No-QueryClient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Steps to reproduce the react-query/vite/pnpm bug

The error:

Error: No QueryClient set, use QueryClientProvider to set one

Steps to reproduce:

pnpm create vite vite-app --template react-ts
mkdir my-lib && cd my-lib && pnpm init
  • add index.ts code to my-lib

  • add dependencies to my-lib/package.json

  • add / replace code in vite-app

  • add dependencies to vite-app/package.json

  • add pnpm-workspace.yaml and run pnpm install in root directory

  • cd vite-app

  • pnpm dev ... react-query works ok in browser ✅

  • pnpm build && pnpm preview ... react-query fails with error in browser ⛔

Note: If you uncomment the line const data = useData_inViteApp(); in App.tsx instead of the original one, then pnpm build && pnpm preview works without error. It seems that the error happens only if the hook function is put into another module that is linked via pnpm workspace.

Used software:

node --version
Node v16.14.0

pnpm --version
7.2.1

tsc --version
Version 4.7.3

Operating System:
Windows 10 Pro 21H1
Build 19043.1706

About

Reproduction steps for a react-query error that I encountered

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published