I’m trying to leverage SSR to display something more meaningful to the users when they first hit the app instead of loading indicator, and then let the rest of app load once the initial html is rendered.
So a simple use case would be:
if it’s a first time user or a signed out user, then display the login form, the login form will be disabled until the client side is initiated
if it’s a returning user, then render page header and let react router initiate and then redirect the user to the home page where the rest of the components will be rendered
However I’m running into some issues:
I’m not sure if there is away to retrieve any information about the user (e.g. user id, the full http request object? some cookie to tell if they’re authenticated?) from the initial request inside the onPageLoad function, it seems to me that the only information I’ve to make a decision on what to render on the server is the path in the url, without any information about the user how can we render anything specific to their state? or am I missing something here?
When the signup form is server rendered and delivered to the user and the user start typing some values in the fields, then the user will lose whatever they typed when the form re-initialize by react at the client
If I attempt to disable the form at the server and enable it at the client, or display a loading then I get the following console warning:
> Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
> (client) <div data-reactroot="" da
> (server) <div class="container-flu
Any insights/tips on how to get something like that working? I’m using React Router V3 and Meteor 1.6
Point 2 is true, we also have this issue. All input will be lost after the initial code was loaded and initialized on the client side. The third point could be fixed if you do enable the form within componentDidMount. This function will only be called on the client, so you won’t get a checksum error.