-
Notifications
You must be signed in to change notification settings - Fork 47.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSR: ReactDOM client and server handling newlines differently causing mismatch warnings #11103
Comments
I don't know if this issue exists prior to React 16. |
👍 Browsers all normalize the newlines to be cc @gaearon |
I'm also fairly certain there are other similar issues with some special unicode codepoints, which the DOM may discard or some browsers could encode differently. EDIT: For one, the DOM will discard |
React |
Hello, I have the same issue, with React 16.2.0 This is when I used HTML escape code inside a render function.
|
I have the same error caused by greater char in the css '>' server renders
|
Please file a new issue with a reproducing case. We don't track discussions in closed issues, and new bugs reported there essentially stay unreported. |
Bug report:
I noticed a "Warning: Text content did not match" warning on certain pages of my isomorphic React app, using React and ReactDOM 16.0.0.
After boiling it down to a simple test case it seems that different kinds of newlines are handled differently, some failing to match. If I do:
Everything is fine, no mismatch error and the words are separated in the browser.
However if I do:
I get:
Except in the JS error console the second foobar reads as one word. This seems to be a Chrome issue, mishandling single \r carriage return. Try
x = 'a\rb';
and it echoes that string to the console as one word. In the browser I see "foobar" as one word.More importantly though if I do Windows newlines:
The result in my app is:
Which definitely seems like a bug in React's reconciliation logic.
Setup:
Full list of NPM deps:
This is a Node/Express app on Node 8.4.0. Browser is macOS Chrome 61.0.3163.100
Workaround:
Preprocess any text that's user-uploaded content to normalize the newlines.
The text was updated successfully, but these errors were encountered: