This commit is contained in:
parent
8e0659a554
commit
534d43bd0b
|
@ -4,19 +4,21 @@ import ReactDOMServer from "react-dom/server";
|
||||||
import { Layout, Form } from "./components";
|
import { Layout, Form } from "./components";
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const doctype = `<!DOCTYPE html>\n`;
|
|
||||||
|
|
||||||
app.use(express.static("static"));
|
app.use(express.static("static"));
|
||||||
|
|
||||||
app.get("/", (req, res) =>
|
app.get("/", (req, res) =>
|
||||||
res.send(
|
res.send(
|
||||||
doctype +
|
render(
|
||||||
ReactDOMServer.renderToStaticMarkup(
|
<Layout>
|
||||||
<Layout>
|
<Form></Form>
|
||||||
<Form></Form>
|
</Layout>
|
||||||
</Layout>
|
)
|
||||||
)
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
app.listen(4000);
|
app.listen(8000);
|
||||||
|
|
||||||
|
function render(component: React.ReactElement): string {
|
||||||
|
return `<!DOCTYPE html>\n${ReactDOMServer.renderToStaticMarkup(component)}`;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue