Improve server side only rendering#497
Improve server side only rendering#497gazab wants to merge 13 commits intoreactjs:masterfrom gazab:fix/improve_ssr
Conversation
|
I'll rebase tomorrow |
dustinsoftware
left a comment
There was a problem hiding this comment.
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. |
dustinsoftware
left a comment
There was a problem hiding this comment.
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