Skip to content

Thirdparty library with nextJS and @tanstack/react-query : No QueryClient set #4346

Closed
@ecyrbe

Description

@ecyrbe

Describe the bug

Hello,

Since @tanstack/react-query v4.3.0 (ESM support) has issues with third party libraries that encapsulate react-query when using it with nextJS (maybe other stacks also, but this is confirmed for nextjs at least)
An example is with @zodios/react v10 (that added support for `@tanstack/react-query v4)

The error message we get is : Error: No QueryClient set, use QueryClientProvider to set one

Your minimal, reproducible example

https://stackblitz.com/edit/github-ke9tby-8mxjkp?file=package.json

Steps to reproduce

V4.2.3, no bug: https://stackblitz.com/edit/github-ke9tby?file=package.json
V4.3.0, with bug: https://stackblitz.com/edit/github-ke9tby-8mxjkp?file=package.json

  • Zodios library is using @tanstack/react-query as a peerdependancy and generates ES6 cjs package
  • There is no duplicates dependancies on package.json and no duplicates on generated lock file

My guess is a combined bug of webpack with esm and the way @tanstack/react-query bundles esm + cjs packages.

Expected behavior

No error should happen

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • Linux Ubuntu, StackBlitz
  • Chrome
  • V100+

react-query version

all versions of @tanstack/react-query > v4.3.0

TypeScript version

v4.8.4

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