-
Notifications
You must be signed in to change notification settings - Fork 927
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
Improve server side only rendering #497
Conversation
I'll rebase tomorrow |
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.
Thanks for the PR! At first glance this looks good..need to test this on my workstation before merging.
It looks like the line endings changed in one of the tests, and some lock files were committed. Can you please remove those changes?
@dustinsoftware fixed! If you wonder why I changed some of the test assertions it's because they made more sense that way. Passing true to either clientOnly or serverOnly, but not both at the same time. Ideally, maybe those parameters should be joined to an enum or something instead. I.e enum RenderMode: ClientAndServer, ClientOnly, ServerOnly. I didn't want to introduce too big changes though so I left it like it was. |
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 good to me. There are a few code style nits but I can fix those after merging.
Merged |
This PR fixes two issues with rendering server side ONLY components:
For example, consider the following code:
@Html.React("HelloWorld", Model, serverOnly: true)
Before the fix this resulted in the following HTML:
<div id="react-container123"><h1>Hello world!</h1></div>
And Html.ReactInitJavaScript() rendered:
<script>ReactDOM.hydrate(React.createElement(HelloWorld, {"name":"example"}), document.getElementById("react-container123"));</script>
despite the serverOnly = true argument
After this fix the component will be rendered like this:
<h1>Hello world!</h1>
and ReactInitJavaScript() won't render anything at all for this component.
This should fix #340