Skip to content

Commit 8529758

Browse files
chriscamplejohnDaniel15
authored andcommitted
Server side rendering issue fix with Remarkable (reactjs#356)
1 parent cef84b0 commit 8529758

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

site/jekyll/getting-started/tutorial.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,11 +995,16 @@ var CommentBox = React.createClass({
995995
});
996996
```
997997

998-
We also need to update the `Comment` component to use `Remarkable` from either `global` or `window`, due to a bug in Remarkable:
998+
We also need to update the `Comment` component to use `Remarkable` from either `global` or `window`, due to a bug in Remarkable. We will do this by creating a function to create an instance of `Remarkable` and then calling it from the `Comment` component:
999999
```javascript{3}
1000+
function createRemarkable() {
1001+
var remarkable = (("undefined" != typeof global) && (global.Remarkable)) ? global.Remarkable : window.Remarkable;
1002+
return new remarkable();
1003+
}
1004+
10001005
var Comment = React.createClass({
10011006
rawMarkup: function () {
1002-
var md = new (global.Remarkable || window.Remarkable)();
1007+
var md = createRemarkable();
10031008
var rawMarkup = md.render(this.props.children.toString());
10041009
return { __html: rawMarkup };
10051010
},

tutorial-code/wwwroot/js/tutorial.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,14 @@ var CommentForm = React.createClass({
103103
}
104104
});
105105

106+
function createRemarkable() {
107+
var remarkable = (("undefined" != typeof global) && (global.Remarkable)) ? global.Remarkable : window.Remarkable;
108+
return new remarkable();
109+
}
110+
106111
var Comment = React.createClass({
107112
rawMarkup: function () {
108-
var md = new (global.Remarkable || window.Remarkable)();
113+
var md = createRemarkable();
109114
var rawMarkup = md.render(this.props.children.toString());
110115
return { __html: rawMarkup };
111116
},

0 commit comments

Comments
 (0)