Skip to content

Warning "Expected server HTML to contain a matching <div> in <div>" #842

Closed
@jsbaltodano

Description

@jsbaltodano

Well I am creating a component with
<%= react_component('NameOfComponent', {}, prerender: false) %>

and React is logging into the console
Warning "Expected server HTML to contain a matching div in div"

For what I seen it does not log it if the component is creating using render instead of hydrate

My question is how can I stop the warning.

I read #828
and then in your code

        if (typeof ReactDOM.hydrate === "function") {
          ReactDOM.hydrate(React.createElement(constructor, props), node);
        } else {
          ReactDOM.render(React.createElement(constructor, props), node);
        }

and I thought, maybe you are forcing the hydrate function.

I did force the same method but without using hydrate and the warning goes away.

System configuration

**Webpacker version 3.0.2:
**React-Rails version 2.4.1:
**Rails version 5.1.4:
**Ruby version2.4.2:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions