-
Notifications
You must be signed in to change notification settings - Fork 926
ReactDOM.hydrate with ClientOnly #521
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
Comments
Thanks for reporting this bug.
…On Thu, Mar 22, 2018 at 05:18, igorroch ***@***.***> wrote:
There is a console error when we try to render component with parameter
clientOnly: true
react-dom.development.js:894 Warning: Expected server HTML to contain a
matching
in
.
@Html.React("ReactWorld", new { name = "World" } ,clientOnly: true )
Minimal repo to reproduce: https://github.com/igorroch/demo
https://stackoverflow.com/questions/46443652/react-16-warning-expected-server-html-to-contain-a-matching-div-in-body
says that "If your application is not ssr, please use ReactDOM.render to
start"
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#521>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AA5hFrADg0MKBs2ISSOBZE9r3aeWZ318ks5tg5aCgaJpZM4S28dg>
.
|
@igorroch are you working on a fix? If not, I'm looking to make my first open source contribution and can take a stab at it! |
@suhailnaw Not working now. I wish to do it, but do not have free time at all. Feel free to take it |
Hi @suhailnaw 👋 let me know if you'd like some help on this one! If you don't have time either let me know and I'll take care of it. |
Hey @dustinsoftware, I do need some help! Is the aim to remove error because now we should be using ReactDOM.hydrate for all cases? |
Per the React docs, Add React.NET/src/React.Core/ReactEnvironment.cs Lines 305 to 309 in 86115d7
When React.NET/src/React.Core/ReactComponent.cs Lines 234 to 241 in 86115d7
Let's make sure to add a unit test for this as well. Here's an example one you can duplicate: React.NET/tests/React.Tests/Core/ReactComponentTest.cs Lines 197 to 214 in d49bb11
|
Hey @dustinsoftware , I just made my first open source PR :D Could you please give me some feedback? I really appreciate all your help and aim to wrap this issue asap! I had to make the changes on my OSX machine and am working on getting my Windows machine up. I will run the linter and test script once I have my Windows machine up, but wanted to get your feedback on where I was going for this bug fix. Let me know what you think! |
* Added ClientOnly property to ReactComponent * added conditional to RenderJavascript to decide between ReactDOM.render vs ReactDOM.hydrate * Added 2 tests to check if correct method ReactDOM.render or ReactDOM.hydrate used when toggling clientOnly parameter in ReactComponent * Made available ClientOnly and correctly implemented ternary operator using Write * Removed redundant call to ClientOnly * Changed tests to correctly take in ClientOnly * Changed incorrect punctuation in test file * Corrected tests to use render if true * Update examples to react 16.4
Fixed |
There is a console error when we try to render component with parameter clientOnly: true
react-dom.development.js:894 Warning: Expected server HTML to contain a matching <div> in <div>.
@Html.React("ReactWorld", new { name = "World" }, clientOnly: true)
Minimal repo to reproduce: https://github.com/igorroch/React.NET-issue-521
https://stackoverflow.com/questions/46443652/react-16-warning-expected-server-html-to-contain-a-matching-div-in-body
says that "If your application is not ssr, please use ReactDOM.render to start"
But now RenderJavaScript() uses only ReactDOM.hydrate for all components.
The text was updated successfully, but these errors were encountered: