Skip to content

Hydration mismatch with React 19 and the latest beta version of this gem #2210

@jukra

Description

@jukra

After upgrading from react_on_rails 16.1.2 to 16.2.0.beta.19, we're experiencing hydration mismatch errors even though we're using client-side only rendering (no prerender: true, server_bundle_js_file is empty). We are not on pro version.

We are using ReactOnRails.reactOnRailsPageLoaded(); when loading components asynchronously.

The error shows that React is attempting to hydrate existing DOM content with kebab-case CSS properties, when it should be doing a fresh client-side render with camelCase properties.

Environment

  1. Ruby version: 3.4.7
  2. Rails version: 8.1
  3. Shakapacker/Webpacker version: 9.4.0
  4. React on Rails version: 16.2.0.beta.19

Expected behavior

No hydration, and no mismatch errors.

Actual behavior

React is attempting to hydrate existing DOM content. The hydration comparison shows:

  • Server/existing DOM: kebab-case CSS (align-items, flex-direction, margin-right)
  • Client React: camelCase CSS (alignItems, flexDirection, marginRight)

Notes

Possibly these changes are related:

Workaround

If you use reactOnRailsComponentLoaded(domId) per component, instead of reactOnRailsPageLoaded(), it works without any issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions