Created
October 1, 2017 14:46
-
-
Save koba04/f6e90c2fb946f5df5faab83f9e8b8b93 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) => { | |
ReactDOMServer.renderToNodeStream( | |
<Html initialData={JSON.stringify(initialData)}> | |
<App {...initialData} name="World" /> | |
</Html> | |
).pipe(res); | |
}); | |
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