GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — React 18 - hydration of lazy component with sibling fails · Issue #23331 · react/react

React 18 - hydration of lazy component with sibling fails #23331

New issue
Copy link
New issue
Copy link
Closed
Closed
React 18 - hydration of lazy component with sibling fails#23331
Copy link
Labels
React 18Bug reports, questions, and general feedback about React 18Type: Needs Investigation

Description

@laverdet
laverdet
opened on Feb 19, 2022
Issue body actions

Hello, I'm having an issue with hydration of SSR components using renderToPipeableStream and hydrateRoot. I have a minimum reproduction case here: https://github.com/laverdet/react-issue. Just run npm install; npm start and navigate to localhost:8000.

The error produced follows:

react-dom.development.js:87 Warning: Prop `id` did not match. Server: "async" Client: "after"
    at span
    at Suspense
    at div

The relevant bits of implementation are reproduced below--

app.jsx

const Async = lazy(async () => import('./hot.jsx') });

export const app = <div>
	<Suspense fallback={<div>Loading...</div>}>
		<Async />
		<span id="after">after</span>
	</Suspense>
</div>;

hot.jsx

export default function Async() {
	return <span id="async">async</span>;
}

If I wrap Async directly in a suspense element it will work: <Suspense fallback={null}><Async /></Suspense>

Activity

  1. laverdet
    added
    React 18Bug reports, questions, and general feedback about React 18
    Type: Discussion
    on Feb 19, 2022
  2. gaearon commented on Feb 19, 2022

    @gaearon
    gaearon
    on Feb 19, 2022
    Collaborator
    More actions

    Can you try turning it into a failing test? You can use this one as a base.

    https://github.com/facebook/react/blob/40eaa22d9af685c239f9d8d42b454d031791e76d/packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js#L238

  3. gaearon
    added
    Type: Needs Investigation
    and removed
    Type: Discussion
    on Feb 19, 2022
  4. laverdet commented on Feb 20, 2022

    @laverdet
    laverdet
    on Feb 20, 2022
    ContributorAuthor
    More actions

    Thanks for the suggestion on how to demonstrate this more clearly for the team. I managed to reproduce in the test environment:
    https://github.com/laverdet/react/commit/6ab56221d64732c99db4aab9d5540e9dab1b614b

    It happens when the server pushes a resolved lazy component but the client hasn't yet downloaded the component and therefore can't render it. I can observe the same workaround where wrapping the lazy component in its own personal <Suspense /> fixes it.

  5. gaearon commented on Feb 20, 2022

    @gaearon
    gaearon
    on Feb 20, 2022
    Collaborator
    More actions

    Thanks! Can you please send it as a PR? Meaning just the failing test.

    Reacted by Marcel Laverdet
  6. acdlite commented on Feb 27, 2022

    @acdlite
    acdlite
    on Feb 27, 2022
    Collaborator
    More actions

    Fixed by #23364

  7. acdlite
    closed this as completedon Feb 27, 2022
  8. dominic-p commented on Jun 7, 2022

    @dominic-p
    dominic-p
    on Jun 7, 2022
    More actions

    I seem to be hitting this same error hydrating an SSR rendered tree with React.lazy components in React 18.1.0.

    If the lazy component has siblings I get:

    Uncaught Error: Hydration failed because the initial UI does not match what was rendered on the server.

    unless I wrap each component in its own <Suspense> element.

    I forked the SSR code sandbox demo and removed the <Suspense> wrapper around the Comments component to reproduce the error:

    Old version (reproduces): https://codesandbox.io/s/elastic-oskar-vkc2gm?file=/src/App.js:1283-1339
    New version (doens't?): https://codesandbox.io/s/frosty-leftpad-d6o506?file=/src/App.js:1283-1328

    I'm still pretty new to Suspense. Is this expected behavior?

    Update: It looks like I was using an old version of the demo in my fork. I can't seem to reproduce it with a modern version even though I'm seeing the same behavior on my app. I'll keep trying to reproduce.

    Update: Never mind. I missed #24384 until just now. If I use 18.2.0-next-e531a4a62-20220505, the error goes away. Sorry for the noise.

    Reacted by wang.haoyu
  9. gaearon commented on Jun 7, 2022

    @gaearon
    gaearon
    on Jun 7, 2022
    Collaborator
    More actions

    No prob. Sorry we haven’t released the fix in stable yet.

    Reacted by Dominic
  10. mrizwanashiq
    added a commit that references this issue on Jun 25, 2026

    Fix false positive hydration warnings (react#23364)

    4344a47
  11. hanzo-dev
    added a commit that references this issue on Sep 9, 2026

    Fix false positive hydration warnings (react#23364)

    e924eeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    React 18Bug reports, questions, and general feedback about React 18Type: Needs Investigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.