Skip to content

react-query hydration in /app/page.tsx thrown error: React.createContext is not a function #41936

@wh5938316

Description

@wh5938316

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:24 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T8101
Binaries:
Node: 18.12.0
npm: 8.19.2
Yarn: 1.22.11
pnpm: 7.13.6
Relevant packages:
next: 12.3.2-canary.43
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0

What browser are you using? (if relevant)

chrome 106.0.5249.119

How are you deploying your application? (if relevant)

No response

Describe the Bug

in /app/page.tsx

import { QueryClient } from "@tanstack/react-query";
...
// throw error
const queryClient = new QueryClient();

thrown error: React.createContext is not a function

Expected Behavior

I want to prefetch data in server component, and then dehydrate it to transfer to client component.
like this: https://tanstack.com/query/v4/docs/guides/ssr

Link to reproduction

https://codesandbox.io/p/github/wh5938316/next13-react-query/main?file=%2Fapp%2Fpage.tsx

To Reproduce

const queryClient = new QueryClient();

in /app/page.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions