Skip to content

Server side rendering issue fix with Remarkable #356

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

Merged
merged 1 commit into from
Jan 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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