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,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)}`;
}