Skip to content

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

@mdeoliveira-hw

Description

@mdeoliveira-hw

Describe the bug

I have a project that consist in multiple packages :

  • a library who export some react-query hooks that define @tanstack/react-query as peerDependency
  • a React app, build with create-react-app that use the library to fetch data.

Both package, used the same version of react and @tanstack/react-query.

Capture d’écran 2023-02-10 à 16 56 26

If we try to use the hooks define in the library from the react app, we got the following error :

Capture d’écran 2023-02-10 à 16 35 47

Your minimal, reproducible example

Steps to reproduce

yarn 
yarn start

Expected behavior

We should be able to use the queryClient in both sides (app + lib).

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS : macOS
  • Browser : Chrome 110.0.5481.77 (Build officiel) (arm64)

TanStack Query version

4.24.4

TypeScript version

4.9.5

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions