-
Notifications
You must be signed in to change notification settings - Fork 47.3k
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
Only render node on Client Side. #4374
Comments
One idea is to render on the client twice: React.render(<MyApp isFirstRender={true}/>, container);
React.render(<MyApp isFirstRender={false}/>, container); |
Would it be sufficient to add a Netflix does this. |
I think the official recommendation at this point would be to use context for things like this. That also allows you to simulate a server-side render for initial mount on the client side, which is a pretty handy trick/feature to make the nodes/checksums align. |
We're using isomorphic rendering in our app, however we want some items to not be present if Javascript is disabled. In our render method we're doing the following:
It works as expected, however we get the 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:
The way to make this go away is to store the check like this:
However, it doesn't seem like this is the "right" place for this to live, maybe I'm wrong. I could also use
this.isMounted()
, however as this is deprecated, it doesn't make much sense to use it.Does anyone else have any thoughts on the best way to approach this?
The text was updated successfully, but these errors were encountered: