question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React renders differently on server and client.

See original GitHub issue

I have read #3152 and #3879 but this seemed like maybe another but related problem.

When the browser tries to bootstrap React and rerender the page I get this 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) e6zyboqo.1.2.1.0.1">"This is a
 (server) e6zyboqo.1.2.1.0.1">"This is a test

Apart from the case that it is unnecessary to escape the quote it seems to render differently on the server and browser. This is just static content so I don’t really understand why?

The markup to render the element is like this.

<p><strong>Next:</strong>"This is a test"</p>

How come it’s rendered different?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:24 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
lalaucommented, Jan 21, 2016

Is this issue about mismtach caused by character encoding (@vlinder) or attribute ordering changed by object.assign (@mridgway)?

I am seeing a similar issue as @mridgway that in some cases the props key ordering is changed by object.assign and then by using the spread operator to specify them causes the server the client to render the attributes in different order.

Since the spec doesn’t specify the ordering the keys in an object, it seems pretty fragile that we take the attribute ordering into account when determining if there is a mismatch. The other way is to have the spread operator returns a consistent ordering, but not sure how you can do that except doing a sort on the keys, which is pretty costly.

1reaction
Downloadcommented, Apr 18, 2016

@mridgway

Our issue turned out to be an issue with the object-assign package switching to using getOwnPropertyNames which returns keys in the wrong order when the object’s key become too large.

Ah!! That sounds like a really good reason for me seeing this 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) ut" id=“textfield-” value=“” type=“text” (server) ut" id=“textfield-” type=“text” value=“”

I have an isomorphic app so I can’t see a reason key ordering should be different… except for what you are saying here. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Render different components on client and server side
I am currently developing a website where I have used react, react-router and redux. We are doing Server side rendering and using react...
Read more >
Flash component renders differently in server vs client #1773
Bla When rendered in NextJS on the server, the HTML it generates becomes: ... Flash component renders differently in server vs client #1773....
Read more >
Client Side Rendering Vs Server Side Rendering in React js ...
In server-side rendering when a user makes a request to a webpage, the server prepares an HTML page by fetching user-specific data and...
Read more >
Client-Side Rendering vs. Server-Side Rendering - Shakacode
You may want different code for your server-rendered components running server side versus client side. For example, if you have an animation that...
Read more >
Client-side vs. server-side rendering: why it's not all black and ...
Server -side rendering is the most common method for displaying information onto the screen. It works by converting HTML files in the server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found