Skip to content

Commit c2d049c

Browse files
author
Dan Mosedale
committed
Nasty hack to make pre-rendered HTML match the dynamic stuff
1 parent b9c0e5e commit c2d049c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

content-src/components/NewTabPage/NewTabPage.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ const NewTabPage = React.createClass({
4949
const recommendationIcon = props.Spotlight.recommendationShown ? "check" : " ";
5050
const showRecommendationOption = props.showRecommendationOption;
5151

52+
// XXX forcibly add # on the server side so that it makes the # added on the
53+
// client side by react-router's createHref() to make pre-rendered and
54+
// dynamically rendered html completely identical so that React doesn't try
55+
// to go to heroical measures to fix things up and (presumably) slow down
56+
// the pre-render. If we decide to stick with this hack, we need to be
57+
// sure it's not necessary for any other <Link>s in the code.
58+
//
59+
// See https://github.com/reactjs/react-router/issues/2111 and
60+
// http://stackoverflow.com/questions/27928372/react-router-urls-dont-work-when-refreshing-or-writting-manually
61+
// for some relevant info.
62+
let debugLinkTo, timelineLinkTo;
63+
if (PRERENDER) {
64+
debugLinkTo = "#/debug";
65+
timelineLinkTo = "#/timeline";
66+
} else {
67+
debugLinkTo = "/debug";
68+
timelineLinkTo = "/timeline";
69+
}
70+
5271
return (<main className="new-tab">
5372
<div className="new-tab-wrapper">
5473
<section>
@@ -77,7 +96,9 @@ const NewTabPage = React.createClass({
7796
</section>
7897

7998
<section className="bottom-links-container">
80-
<Link className="bottom-link" to="/timeline"><span className="icon icon-spacer icon-activity-stream" /> See all activity</Link>
99+
<Link className="bottom-link" to={timelineLinkTo}>
100+
<span className="icon icon-spacer icon-activity-stream" /> See all activity
101+
</Link>
81102
<span className="link-wrapper-right">
82103
<a
83104
ref="settingsLink"
@@ -98,7 +119,7 @@ const NewTabPage = React.createClass({
98119
</div>
99120
</div>
100121

101-
<Link className="debug-link" to="/debug">debug</Link>
122+
<Link className="debug-link" to={debugLinkTo}>debug</Link>
102123
</main>);
103124
}
104125
});

0 commit comments

Comments
 (0)