This commit is contained in:
Leandro Facchinetti 2020-03-18 11:12:46 -04:00
parent 8e0659a554
commit 534d43bd0b
1 changed files with 10 additions and 8 deletions

View File

@ -4,14 +4,12 @@ import ReactDOMServer from "react-dom/server";
import { Layout, Form } from "./components";
const app = express();
const doctype = `<!DOCTYPE html>\n`;
app.use(express.static("static"));
app.get("/", (req, res) =>
res.send(
doctype +
ReactDOMServer.renderToStaticMarkup(
render(
<Layout>
<Form></Form>
</Layout>
@ -19,4 +17,8 @@ app.get("/", (req, res) =>
)
);
app.listen(4000);
app.listen(8000);
function render(component: React.ReactElement): string {
return `<!DOCTYPE html>\n${ReactDOMServer.renderToStaticMarkup(component)}`;
}