Describe the bug#
In #4738 the use client directive was added to client-side files but trying to use the React Query Devtools is throwing errors attached below:
error - ./node_modules/@tanstack/react-query-devtools/build/lib/Explorer.mjs
Attempted import error: 'useState' is not exported from 'react' (imported as 'React').
Import trace for requested module:
./node_modules/@tanstack/react-query-devtools/build/lib/Explorer.mjs
./node_modules/@tanstack/react-query-devtools/build/lib/devtools.mjs
./node_modules/@tanstack/react-query-devtools/build/lib/index.mjs
./src/app/layout.tsx

Your minimal, reproducible example#
https://github.com/ChristianIvicevic/tanstack-query-rsc-use-client-issue
Steps to reproduce#
npm install
npm run dev
- Open the application
Expected behavior#
No server error with the devtools being available.
How often does this bug happen?#
Every time
Screenshots or Videos#
No response
Platform#
Not relevant.
TanStack Query version#
4.23.0
TypeScript version#
No response
Additional context#
No response
I think we forgot to add
'use client'to the index file of the devtools:https://github.com/TanStack/query/blob/d4fa2b98cf1b6a1f8a2722f5983e71a199c80c85/packages/react-query-devtools/src/index.ts
Would you like to contribute that to see if that fixes it?
Workaround: It works if you move the devtools rendering to a client component like
Providers:https://codesandbox.io/p/sandbox/upbeat-sun-b9pq0q?file=%2Fsrc%2Fapp%2Fclient.tsx&selection=%5B%7B%22endColumn%22%3A17%2C%22endLineNumber%22%3A12%2C%22startColumn%22%3A17%2C%22startLineNumber%22%3A12%7D%5D