Skip to content

[React 15+] Cloudflare's HTML minification causes isomorphic React app to crash #10778

Closed

Description

@gaulucky92

I think this is not a bug, it's a compatibility issue.

In React v15.x+, the server-sided HTML rendered by react-dom/server's function renderToString() contains some comment tags that represent null components (instead of <noscript> tags like React v0.14.x), which is really neat.
Unfortunately, when the app is served by Cloudflare with HTML minification enabled, it automatically removes all the comment tags, including the ones generated by React.
This behavior causes the client app to crash, and throws an error:

Unable to find element with ID x.

With x is a number, usually the null component's react-id.

The problem can be solved by disabling HTML minification on Cloudflare, but the question is, is it possible to earn the benefit from HTML minification, while keep the app running well?

React/ReactDOM version: 15.6.1
Node version: 6.10.0 / 6.10.3

Activity

  1. gaearon commented on Sep 22, 2017

    @gaearon
    Contributor

    I might be wrong but I think React 16 (a release candidate is out and you can try it) doesn't use comments.

  2. gaulucky92 commented on Sep 26, 2017

    @gaulucky92
    Author

    @gaearon Thanks for your suggestion. I am using React 15 on production, so I think it's not a good idea to try the RC of React 16. Anyway, being recommended to try React 16, should I understand that there are no solutions for React 15?

  3. gaearon commented on Sep 26, 2017

    @gaearon
    Contributor

    This is correct. React 15 relies on comments. React 16 does not.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions