-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathHtml.js
49 lines (46 loc) · 1.43 KB
/
Html.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom/server';
import Helmet from 'react-helmet';
import serialize from 'serialize-javascript';
export default class Html extends Component {
static propTypes = {
component: PropTypes.node,
store: PropTypes.object
};
render() {
const { component, store } = this.props;
const content = component ? ReactDOM.renderToString(component) : '';
const head = Helmet.rewind();
return (
<html lang="en-us">
<head>
{head.base.toComponent()}
{head.title.toComponent()}
{head.meta.toComponent()}
{head.link.toComponent()}
{head.script.toComponent()}
<link rel="shortcut icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
href="/pack/styles.css"
media="screen, projection"
rel="stylesheet"
type="text/css"
charSet="UTF-8"
/>
</head>
<body>
<div id="content" dangerouslySetInnerHTML={{ __html: content }} />
<script
dangerouslySetInnerHTML =
{
{ __html: `window.__data=${serialize(store.getState())};` }
}
charSet="UTF-8"
/>
<script src="/pack/client.generated.js" charSet="UTF-8" />
</body>
</html>
);
}
}