-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
44 lines (36 loc) · 1.09 KB
/
test.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
var React = require('react');
Error.stackTraceLimit = Infinity;
var StaticMarkupRenderComponent = React.createClass({
render() {
var stuffToRender = React.DOM.noscript({}, React.DOM.img({src: 'tracking-fallback-pixel.png'}));
var staticContent = React.renderToStaticMarkup(stuffToRender);
var getStaticContent = () => ({__html: staticContent});
return React.DOM.div({dangerouslySetInnerHTML: getStaticContent()});
}
});
var ComponentWillMountSetStateComponent = React.createClass({
componentWillMount() {
this.setState({groovy: 'doovy'});
},
render() {
return React.DOM.div({}, this.state.groovy);
}
});
// Works
var staticRenderLast = React.renderToString(
React.DOM.div(
{},
React.createElement(ComponentWillMountSetStateComponent),
React.createElement(StaticMarkupRenderComponent)
)
);
console.log(staticRenderLast);
// Works
var staticRenderFirst = React.renderToString(
React.DOM.div(
{},
React.createElement(StaticMarkupRenderComponent),
React.createElement(ComponentWillMountSetStateComponent)
)
);
console.log(staticRenderFirst);