Last active
December 17, 2015 23:33
-
-
Save mobinni/55d1e949e1369557fab7 to your computer and use it in GitHub Desktop.
A Modern Isomorphic Stack with Redux - Part 1
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 {RoutingContext} from 'react-router'; | |
import ejs from 'ejs'; | |
import React from 'react'; | |
import ReactDOMServer from 'react-dom/server'; | |
const _renderComponents = (props) => { | |
return ReactDOMServer.renderToString( | |
<RoutingContext {...props} /> | |
); | |
}; | |
export default (shouldRender, renderProps, indexHtml) => { | |
return new Promise((resolve, reject) => { | |
let output = shouldRender ? _renderComponents(renderProps) : ''; | |
resolve( | |
ejs.render(indexHtml, { | |
reactOutput: output | |
}) | |
); | |
}); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment