Skip to content

Unable to use @tanstak/react-query in a monorepo - nx #5445

@MathurAditya724

Description

@MathurAditya724

Describe the bug

my team and I are trying to shift all our application's codebase to nx, but due to some problem with Tanstack react query it is showing Invalid hook call.

We tried creating a new repo and removed the shared-ui lib (cause we thought it might be the cause of the peerDependencies as mentioned here

We were able to run it when had a standalone next app created using create-next-app

In the attached repo the code is very simple, it's just

<QueryClientProvider client={client}>
  <Component {...pageProps} />
</QueryClientProvider>

we tried this with macOS also thinking it might be a Windows error but apparently, it was not

Your minimal, reproducible example

https://github.com/MathurAditya724/tanstack_error

Steps to reproduce

// Install all the dependencies
npm i

// Run the report server
npx nx run report:serve

Expected behavior

The application code we have given in the repo should just work, Idk if it's a config issue or a problem with nx. We were just creating the repo with the nx guide to create an integrated mono repo.

How often does this bug happen?

Every time

Screenshots or Videos

error_1
error_2

Platform

Node   : 18.7.0
OS     : win32 x64
npm    : 9.6.5
Hasher : Native
   
nx                 : 16.2.1
@nx/js             : 16.2.1
@nx/jest           : 16.2.1
@nx/linter         : 16.2.1
@nx/workspace      : 16.2.1
@nx/cypress        : 16.2.1
@nx/devkit         : 16.2.1
@nx/eslint-plugin  : 16.2.1
@nx/nest           : 16.2.1
@nx/next           : 16.2.1
@nx/node           : 16.2.1
@nx/react          : 16.2.1
@nrwl/tao          : 16.2.1
@nx/vite           : 16.2.1
@nx/web            : 16.2.1
@nx/webpack        : 16.2.1
typescript         : 5.0.4

Tanstack Query adapter

react-query

TanStack Query version

v4.29.7

TypeScript version

~5.0.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions