vercel / vercel/next.js

Enabling `experimental.reactCompiler` causes hydration error when using styled-jsx

Open
#65,995 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/marmalade-labs/react-compiler-styled-jsx

To Reproduce
  1. Start the dev server bun dev
  2. Load the page http://localhost:3000/
  3. Notice the hydration mismatch error printed in the Console
Current vs. Expected behavior

Current behavior

The styled-jsx ID is successfully rendered on the server, but it is not being rendered on the client
image

Expected behavior

The styled-jsx ID should be present in both the server and client output

Provide environment information
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Fri, 17 May 2024 16:56:38 +0000
  Available memory (MB): 31884
  Available CPU cores: 8
Binaries:
  Node: 18.20.2
  npm: 10.8.0
  Yarn: 1.22.22
  pnpm: 8.15.5
Relevant Packages:
  next: 14.3.0-canary.72 // Latest available version is detected (14.3.0-canary.72).
  eslint-config-next: 14.3.0-canary.72
  react: 19.0.0-rc-d3ce0d3ea9-20240520
  react-dom: 19.0.0-rc-d3ce0d3ea9-20240520
  typescript: 5.4.5
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Clone the linked reproduction and run bun dev, then inspect how enabling experimental.reactCompiler affects the server and client styled-jsx output. Compare the rendered styled-jsx IDs and hydration console error; done means the ID is present in both outputs and the hydration mismatch no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs, react
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.