Skip to content

Instantly share code, notes, and snippets.

@navgarcha
Created July 30, 2016 10:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save navgarcha/ac77b7d9d350e9cd3da594b8c7e252f6 to your computer and use it in GitHub Desktop.
Save navgarcha/ac77b7d9d350e9cd3da594b8c7e252f6 to your computer and use it in GitHub Desktop.
function requestContextData(store = {}, { components = [] }) {
const promises = components.reduce((prev, current = {}) => {
return (current.need || []).concat(prev);
}, []).map((need) => store.dispatch(need()));
return Promise.all(promises);
}
// ...
requestContextData(store, props).then(() => {
const state = store.getState();
const html = renderToString(rootComponent);
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment