Skip to content

Ignore <noscript> content on the client and don't warn about mismatches  #11423

Description

@stephen-last

React 16.0.0 with SSR & lazysizes 4.0.1.

Trying to use the "the noscript pattern" to lazy load images with lazysizes but I'm seeing this:

Warning: Expected server HTML to contain a matching <img> in <noscript>.

Image component render method:

render () {
    const { cdn, url, width, height } = this.props

    if (!url) return null

    const noScriptImgProps = {
      src: `${cdn}${url}`,
      className: classNames('product-image'),
      width,
      height
    }

    const imgProps = {
      'data-src': `${cdn}${url}`,
      className: classNames('product-image', 'lazyload'),
      width,
      height
    }

    return (
      <span>
        <noscript>
          <img {...noScriptImgProps} />
        </noscript>
        <img {...imgProps} />
      </span>
    )
  }

Does React have an issue with noscript tags..?

Activity

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

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