-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Isomorphic Rendering with inserted html broken. (15.0) #6452
Comments
What does the rest of that warning say? |
@zpao I'm having problems with server side rendering also. When using 15.0.0-rc.2, everything was working smooth, but after update, I'm receiving this message: {"error":"React.__spread is not a function"} Tried to reinstall all my dependencies and the error persists. Tried to install the previous version (RC2), and it started working again, smoothly. |
I'm pretty sure this is just the same as #6451 so I'm going to close this out. Let me know if I'm incorrect in that assumption. |
@zpao this is unrelated to #6451. Here is the full stack trace: index.js:65 Invariant Violation: You're trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side:
(client) data-reactid="13"></head><body data-rea
(server) data-reactid="13"><style type="text/css
at invariant (http://efca.localhost.ca:3002/admin/js/app.js:34199:15)
at Object.ReactMount._mountImageIntoNode (http://efca.localhost.ca:3002/admin/js/app.js:83566:91)
at Object.wrapper [as _mountImageIntoNode] (http://efca.localhost.ca:3002/admin/js/app.js:84437:21)
at mountComponentIntoNode (http://efca.localhost.ca:3002/admin/js/app.js:83225:14)
at ReactReconcileTransaction.Mixin.perform (http://efca.localhost.ca:3002/admin/js/app.js:87875:20)
at batchedMountComponentIntoNode (http://efca.localhost.ca:3002/admin/js/app.js:83239:15)
at ReactDefaultBatchingStrategyTransaction.Mixin.perform (http://efca.localhost.ca:3002/admin/js/app.js:87875:20)
at Object.ReactDefaultBatchingStrategy.batchedUpdates (http://efca.localhost.ca:3002/admin/js/app.js:81259:19)
at Object.batchedUpdates (http://efca.localhost.ca:3002/admin/js/app.js:85595:20)
at Object.ReactMount._renderNewRootComponent (http://efca.localhost.ca:3002/admin/js/app.js:83392:18) The issue is to due with nodes (in this case a This works in Ideally react would ignore anything without a |
@spicyj How has the checksum check changed now that we're using createElement? Before it would work in this case because we'd be looking at the checksum of the generated markup string which wouldn't have seen the actual DOM. Or is this actually a case where the warning uses outerHTML so this mismatch is just pointing at the wrong thing. |
In my application we have a chunk of code that is executed when the Interestingly this was a race condition as sometimes React's initial render would happen before the additional stylesheet was injected, and all would be fine. |
@zpao Nothing's changed – we still generate HTML client-side when reviving server-rendered markup. |
@DylanPiercey The checksum still would not be thrown off by anything added by an adblocker like this (and should work identically to 0.14.7). The error message is misleading in this case though. If you disable your adblocker, what error do you get instead? |
Going to close this because it's unlikely this is actually a React bug but please reply and we can continue to debug. |
@spicyj Sorry for not replying quicker. I tried 0.15x on a couple other projects with similar setups and it works fine so this must be something specific to the project. This can stay closed, thanks. |
No worries, I just wanted to clarify my earlier comments. Didn't mean to put any pressure on you to reply quickly! If you have more trouble with that project then feel free to post and we'll figure out what's going on. |
@DylanPiercey - Were you able to solve this issue. if yes can you share some pointers.. I am facing the similar issue on upgrading react from 0.14x to 15 ..
|
@mgmn ultimately we made 100% sure that the server rendered output was the same (this was tricky for some dates for unknown users). There was also setup a way to catch the error and discard the dom if needed. My larger problem and the reason I created this issue was that react was broken for people who used browser extensions in some cases but I believe that was fixed when they removed data-reactid. Sorry if that doesn’t help any. This issue is also pretty old so perhaps it was fixed in react 16. |
In React 0.14x and below inserted dom nodes inserted by plugins such as adblock, browser sync, or otherwise were ignored.
Now in React 15 these new nodes cause the
index.js:65 Invariant Violation: You're trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side:
I'd say this is a regression since it breaks (full page) isomorphic rendering for anyone using plugins (or scripts) that insert dom when loaded.
I'd say react should just ignore anything without a "data-reactid" when mounting server rendered code.
Edit:
On top of this React now throws in this case, where as before it would gracefully continue.
The text was updated successfully, but these errors were encountered: