Преглед на файлове

first attempt at server-side rendering

it's not really useful because CommentBox takes a url, but if we pass
the data directly instead it should work. (or maybe provide it as
"initialData" or something like it.)
Lucas Stadler преди 11 години
родител
ревизия
6e40b09d9c
променени са 1 файла, в които са добавени 25 реда и са изтрити 0 реда
  1. 25 0
      js/react/static.js

+ 25 - 0
js/react/static.js

@ -0,0 +1,25 @@
1
import fs from "fs";
2
import React from "react";
3
4
import {CommentBox} from "./comments.js";
5
6
let commentsHtml = React.renderToString(<CommentBox url="comments.json" />);
7
8
let html = `<!doctype html>
9
<html>
10
  <head>
11
    <meta charset="utf-8" />
12
    <title>Hi, React! (static...)</title>
13
  </head>
14
15
  <body>
16
    <div id="content">
17
    	${commentsHtml}
18
    </div>
19
20
    <script src="bundle.js"></script>
21
  </body>
22
</html>
23
`
24
25
console.log(html);