This commit is contained in:
parent
8e0659a554
commit
534d43bd0b
|
@ -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)}`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue