Skip to content

SSR + <img/> + dangerouslySetInnerHTMl = problem #6063

@ivan-kleshnin

Description

@ivan-kleshnin

Bug report

I think I've found a bug with hydration. I believe it's a bug of NextJS because I didn't have it before I switched to NextJS (from my custom SSR implementation).

Describe the bug

The following renders normally

<div dangerouslySetInnerHTML={{__html: "<span>xxx</span>"}}>
</div>

The following fails

<div dangerouslySetInnerHTML={{__html: "<img src='xxx'/>"}}>
</div>

on client with message

Warning: Prop dangerouslySetInnerHTML did not match.
Server: "<img src="test" style="">"
Client: "<img src="test">"

Note the empty style tag which causes the mismatch.

System information

  • Version of Next.js: 7.0.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