You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[React 15+] Cloudflare's HTML minification causes isomorphic React app to crash #10778
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?
@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?
Activity
gaearon commentedon Sep 22, 2017
I might be wrong but I think React 16 (a release candidate is out and you can try it) doesn't use comments.
gaulucky92 commentedon Sep 26, 2017
@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?
gaearon commentedon Sep 26, 2017
This is correct. React 15 relies on comments. React 16 does not.