Skip to content
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

Link makes checksum incompatible #528

Closed
clintandrewhall opened this issue Nov 27, 2014 · 17 comments
Closed

Link makes checksum incompatible #528

clintandrewhall opened this issue Nov 27, 2014 · 17 comments

Comments

@clintandrewhall
Copy link

I'm experimenting with isomorphic rendering with react-router, and everything has been going great until I tried to add the Link component. Now I get:

Uncaught Error: Invariant Violation: You're trying to render a component to the document using server rendering but the checksum was invalid. This usually means you rendered a different component type or props on the client from the one on the server, or your render() methods are impure. React cannot handle this case due to cross-browser quirks by rendering at the document root. You should look for environment dependent code in your components and ensure the props are the same client and server side.

If I don't include the Link component, the checksum matches; include even just one and it doesn't. Any ideas what might be causing this?

@gaearon
Copy link
Contributor

gaearon commented Nov 27, 2014

Just wondering.. could it be that you have two different versions of React loaded alongside, one from your app and another in node_modules/react-router/node_modules/react? It's a common source of bugs so just wanna make sure.

@clintandrewhall
Copy link
Author

I'll check and update here... thanks for the lead!

@clintandrewhall
Copy link
Author

Nope. react-router is using the version of react I've loaded in my project: 0.12.x Other suggestions?

@clintandrewhall
Copy link
Author

Any other suggestions?

@gaearon
Copy link
Contributor

gaearon commented Dec 7, 2014

If you share an example, I can take a look!

@clintandrewhall
Copy link
Author

Sure, no problem!

My project metaphorical.ly uses react-router. Here is where I invoke the "overwrite" of the server-produced content:

https://github.com/clintandrewhall/metaphorically/blob/master/public/components/Root.jsx#L72

If I switch just one of these links to Link, I get a checksum error:

https://github.com/clintandrewhall/metaphorically/blob/master/public/components/Nav.jsx#L16

I can provide more info if needed! If you want to run this yourself, just run
node build
node startup.js

@gpbl
Copy link

gpbl commented Dec 7, 2014

@clintandrewhall, once I got this error because the client was rendering the href attribute with #, while the server without it.

@ryanflorence
Copy link
Member

I'm doing plenty of isomorphic stuff right now and have not seen this, I'll happily reopen if a test case showing the bad behavior shows up :)

@ryanflorence
Copy link
Member

woops, missed the sample code

@ryanflorence ryanflorence reopened this Feb 1, 2015
@ryanflorence
Copy link
Member

If you're doing server side rendering, you need to be using Router.HistoryLocation. I'm sure your checksums are busted because of #.

If there's a valid reason to use HashLocation I'll reopen, but browsers don't send the hash to servers anyway.

@clintandrewhall
Copy link
Author

@rpflorence Sorry, what do you mean when you say use Router.HistoryLocation?

@ryanflorence
Copy link
Member

in the client you need to use Router.run(routes, Router.HistoryLocation, callback), and on the server Router.run(routes, req.path, callback).

@HzJavier
Copy link

HzJavier commented May 7, 2015

@clintandrewhall Were you able to fix the problem with that Ryan commented or did something else? I'm having the same issue but didn't quite get the way to solve it.

@iyoukeyyewei
Copy link

I have the same issue. Anyone can help on resolution? thanks

@anatomic
Copy link

I've stumbled on this thread because my checksum isn't matching. Debugging it a few different ways I think the issue is that a <noscript> is being rendered by React on the client while React Router performs it's async work (and secondary bundles are loaded in by webpack). I fear that the universal javascript and webpack chunking may never play well together :(

Has anyone else seen this issue?

@jarib
Copy link

jarib commented Jul 9, 2015

I'm also seeing a <noscript> difference.

image

@anatomic Did you find a solution?

@anatomic
Copy link

anatomic commented Jul 9, 2015

@jarib I did, posted my solution in issue #1402 #1402 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants