Skip to content

Commit

Permalink
Server side rendering issue fix with Remarkable (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscamplejohn authored and Daniel15 committed Jan 5, 2017
1 parent cef84b0 commit 8529758
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions site/jekyll/getting-started/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -995,11 +995,16 @@ var CommentBox = React.createClass({
});
```

We also need to update the `Comment` component to use `Remarkable` from either `global` or `window`, due to a bug in Remarkable:
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:
```javascript{3}
function createRemarkable() {
var remarkable = (("undefined" != typeof global) && (global.Remarkable)) ? global.Remarkable : window.Remarkable;
return new remarkable();
}
var Comment = React.createClass({
rawMarkup: function () {
var md = new (global.Remarkable || window.Remarkable)();
var md = createRemarkable();
var rawMarkup = md.render(this.props.children.toString());
return { __html: rawMarkup };
},
Expand Down
7 changes: 6 additions & 1 deletion tutorial-code/wwwroot/js/tutorial.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ var CommentForm = React.createClass({
}
});

function createRemarkable() {
var remarkable = (("undefined" != typeof global) && (global.Remarkable)) ? global.Remarkable : window.Remarkable;
return new remarkable();
}

var Comment = React.createClass({
rawMarkup: function () {
var md = new (global.Remarkable || window.Remarkable)();
var md = createRemarkable();
var rawMarkup = md.render(this.props.children.toString());
return { __html: rawMarkup };
},
Expand Down

0 comments on commit 8529758

Please sign in to comment.