Created
May 13, 2015 07:14
-
-
Save AndersNS/5a5a76a12cf80a717a86 to your computer and use it in GitHub Desktop.
Isomorphic snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import React from 'react'; | |
export default class Html extends React.Component { | |
render() { | |
return ( | |
<html> | |
<head> | |
<title>{this.props.title}</title> | |
<link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.6.0/pure-min.css" /> | |
</head> | |
<body> | |
<section id="react-section" dangerouslySetInnerHTML={{__html: this.props.markup}}> | |
</section> | |
<script src="/public/js/bundle.js"></script> | |
</body> | |
</html> | |
); | |
} | |
} | |
Html.propTypes = { | |
title: React.PropTypes.string.isRequired, | |
markup: React.PropTypes.string.isRequired | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// express.js stuff | |
// Find title. Generate markup | |
let html = React.renderToStaticMarkup(<Html title={title} markup={markup} />); | |
let resp = '<!DOCTYPE html>' + html; | |
res.send(resp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment