-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
Use ReactDOM.hydrate() for hydrating a SSR component if available #1028
Use ReactDOM.hydrate() for hydrating a SSR component if available #1028
Conversation
@theJoeBiz Any way to test or verify this for both older React and new react? |
@justin808 I don't think so. There aren't any existing tests for |
Also, only one test needs to be updated for a react 16 upgrade |
@alexfedoseev can you please confirm this React syntax looks good. |
node_package/src/clientStartup.js
Outdated
ReactDOM.hydrate && | ||
domNode && | ||
domNode.hasAttribute('data-reactroot') | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you mix things here you shouldn't mix. E.g. !!ReactDOM.hydrate
is enough for shouldHydrate
decision, but if something is wrong w/ dom node then it's out of scope ReactDOM.hydrate
vs ReactDOM.render
problem.
Also, facebook/react#10971
51b40de
to
0bf1415
Compare
@alexfedoseev Good call, updated to just check for truthiness of ReactDOM.hydrate. |
@alexfedoseev let me know if I should merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
We just moved our app into production with this warning, which is fine, but I was just revisiting this on a page that has a combination of server/client rendered components and found a flaw. Turns out, the const shouldHydrate = !!ReactDOM.hydrate && !!domNode.innerHTML; I tested this most recent commit locally on a page using React 16 and a combination of server/client rendered components. Here is the output from the console:
|
@alexfedoseev Please look at the latest change. I know we want to use this as well. |
@theJoeBiz can you please rebase on top of master and add an entry to the CHANGELOG.md |
60e3ddf
to
89fde6a
Compare
d87313b
to
9e86b75
Compare
@justin808 added an entry to CHANGELOG.md and squashed the commits |
LGTM |
Shipped! 10.1.2 |
Any estimate on getting this onto npm as 10.1.2? |
@theJoeBiz it should have published. I'm looking into it. |
Looks like this was originally addressed in #1013, but was closed by accident and never reopened. My project is using React 16 and I can confirm that this patch prevents the deprecation warning.
This change is