Skip to content

Instantly share code, notes, and snippets.

@AndersNS
Created May 13, 2015 07:14
Show Gist options
  • Save AndersNS/5a5a76a12cf80a717a86 to your computer and use it in GitHub Desktop.
Save AndersNS/5a5a76a12cf80a717a86 to your computer and use it in GitHub Desktop.
Isomorphic snippet
'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
};
// 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