Skip to content

Instantly share code, notes, and snippets.

@mobinni
Last active December 17, 2015 23:33
Show Gist options
  • Save mobinni/55d1e949e1369557fab7 to your computer and use it in GitHub Desktop.
Save mobinni/55d1e949e1369557fab7 to your computer and use it in GitHub Desktop.
A Modern Isomorphic Stack with Redux - Part 1
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