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

Issue when rendering server side with react (checksum warning) #4501

Closed
swernerx opened this issue Feb 9, 2017 · 2 comments
Closed

Issue when rendering server side with react (checksum warning) #4501

swernerx opened this issue Feb 9, 2017 · 2 comments

Comments

@swernerx
Copy link

swernerx commented Feb 9, 2017

It seems like NavLink is behaving differently on client and server.

I have this code in my application:

import { Switch, Route, NavLink } from "react-router-dom"

...

<ul>
  <li><NavLink to="/" activeClassName={Styles.activeLink}>Home</NavLink></li>
  <li><NavLink to="/about" activeClassName={Styles.activeLink}>About</NavLink></li>
</ul>

In the markup this seems to produce double slashes for href:

<ul data-reactid="7">
<li data-reactid="8"><a class="src-app-AppContainer-activeLink " href="//" data-reactid="9">Home</a></li>
<li data-reactid="10"><a href="//about" data-reactid="11">About</a></li>
</ul>

That's the warning I am seeing in the client:

warning.js:36 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) activeLink " href="/" data-reactid="9">H
 (server) activeLink " href="//" data-reactid="9">
@pshrmn
Copy link
Contributor

pshrmn commented Feb 9, 2017

Fixed in #4484

@pshrmn pshrmn closed this as completed Feb 9, 2017
@swernerx
Copy link
Author

swernerx commented Feb 9, 2017

Ah perfect 👍

@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
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

2 participants