Created
October 1, 2017 14:32
-
-
Save koba04/af171ff68b4983ff632c7e8544443c5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOMServer from 'react-dom/server'; | |
import express from 'express'; | |
import Html from './Html'; | |
import App from './App'; | |
const app = express(); | |
app.use('/static', express.static('public')); | |
const initialData = { | |
name: 'World' | |
}; | |
app.get('/', (req, res) => { | |
res.send( | |
ReactDOMServer.renderToStaticMarkup( | |
<Html | |
markup={ReactDOMServer.renderToString(<App {...initialData} />)} | |
initialData={JSON.stringify(initialData)} | |
/> | |
) | |
); | |
}); | |
app.listen(3000);, () => { | |
console.log('listening on port 3000...'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment