Skip to content

Commit 1de7cd7

Browse files
author
Jeon JaeHyeong
committed
bug fix: solve client rendering
1 parent 8175bb4 commit 1de7cd7

5 files changed

Lines changed: 17 additions & 19 deletions

File tree

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* HTML template engine: nashorn(react-dom-server)
44
* dynamic html: react js
55

6+
![capture](https://raw.githubusercontent.com/tinywind/REACT-PRACTICE-WEB/master/capture.png "comment")
7+
8+
69
# How to Run
710
* run se.olapetersson.ReactiveApplication.class
811
* add lobby: http://localhost:8080/lobbies/{lobby-name}
@@ -14,14 +17,10 @@
1417
* jpa
1518
* h2 database
1619
* react js
17-
1820
* babel-gen: https://github.com/tinywind/BABEL-CODEGEN
19-
20-
**_BABEL-CODEGEN_ is not deployed to public maven repository, yet.**
21-
21+
**_BABEL-CODEGEN_ is not deployed to public maven repository, yet.**
2222
* lombok
23-
24-
**If fail compile on any IDE, you check the IDE support _lombok_.**
23+
**If fail compile on any IDE, you check the IDE support _lombok_.**
2524

2625
# References
2726
* http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle

capture.png

163 KB
Loading

src/main/resources/static/js/doms.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ var Head = React.createClass({
1313
<script src="/webjars/react/15.1.0/react.min.js"></script>
1414
<script src="/webjars/react/15.1.0/react-dom.min.js"></script>
1515
<script src="/webjars/requirejs-babel/0.0.8/babel-5.8.22.min.js"></script>
16+
<script src="/js/doms.js"></script>
17+
<script src="/js/playfield.js"></script>
1618
</head>
1719
)
1820
}

src/main/resources/static/js/playfield.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var LobbyCard = React.createClass({
33
var title = this.props.title;
44
return (
55
<div className="jumbotron">
6-
<h3>{title}</h3>
6+
<h5>{title}</h5>
77
</div>
88
);
99
}
@@ -54,7 +54,7 @@ var PlayField = React.createClass({
5454
}
5555
return (
5656
<div className="jumbotron container-fluid">
57-
<h2>Lobbies</h2>
57+
<h4>Lobbies</h4>
5858
{lobbies}
5959
</div>
6060
);

src/main/resources/templates/home.jsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var Comment = React.createClass({
22
render: function () {
33
return (
44
<div>
5-
<h2>{ this.props.author }</h2>
5+
<h4>{ this.props.author }</h4>
66
<p>{ this.props.content } </p>
77
</div>
88
)
@@ -24,29 +24,26 @@ var CommentList = React.createClass({
2424
});
2525

2626
React.createClass({
27-
containerConstructorString: function () {
28-
return "ReactDOM.render(<PlayField />, document.getElementById('container'))";
29-
},
27+
containerConstructorString: "ReactDOM.render(<PlayField />, document.getElementById('container'));",
3028
render: function () {
29+
var style = {padding: '1em'};
3130
return (
3231
<html>
3332
<Head title={this.props.title}/>
3433
<body>
35-
<div>
36-
<h1>Render on Server side</h1>
34+
<h1>Render on Server side</h1>
35+
<div style={style}>
3736
<PlayField/>
3837
<CommentList comments={this.props.comments}/>
3938
</div>
4039
<hr/>
4140
<hr/>
42-
<div>
43-
<h1>Render on Client side</h1>
41+
<h1>Render on Client side</h1>
42+
<div style={style}>
4443
<div id="container">
4544
"Not React Rendering"
4645
</div>
47-
<script type="text/babel">
48-
{this.containerConstructorString()}
49-
</script>
46+
<script type="text/babel" dangerouslySetInnerHTML={{__html:this.containerConstructorString}}></script>
5047
</div>
5148
</body>
5249
</html>

0 commit comments

Comments
 (0)