添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Error: No QueryClient set, use QueryClientProvider to set one #7965

@msobiecki

Description

Describe the bug

When using the @tanstack/react-query v5 library within a Turborepo monorepo structure, specifically inside a shared library, the following error is thrown:

Error: No QueryClient set, use QueryClientProvider to set one.

Your minimal, reproducible example

https://github.com/msobiecki/react-query-repro

Steps to reproduce

Reproduction Steps:

  • Set up a Turborepo monorepo with multiple packages, including a shared UI or API library.
  • Install @tanstack/react-query v5 in the shared package.
  • Import and use React Query hooks or components (e.g., useQuery) from the shared library in any consuming application within the monorepo.
  • Run the application.
  • Demo:

  • pnpm install && pnpm run dev
  • Expected behavior

    The @tanstack/react-query library should function as expected within the shared library.

    How often does this bug happen?

    Every time

    Screenshots or Videos

    Platform

  • OS: Linux
  • package manager: pnpm 8.15.9
  • Tanstack Query adapter

    react-query

    TanStack Query version

    5.52.2

    TypeScript version

    5.3.3

    Additional context

    No response