Skip to content

Instantly share code, notes, and snippets.

@JakeGinnivan
Last active September 4, 2019 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeGinnivan/b5e4f0774af391261ff9439c4c0cfc4a to your computer and use it in GitHub Desktop.
Save JakeGinnivan/b5e4f0774af391261ff9439c4c0cfc4a to your computer and use it in GitHub Desktop.
// Note, doesn't deal with timeouts, infinite recursion, errors etc..
async function resolveAll(render, promiseTracker) {
const renderResult = render(promiseTracker)
if (promiseTracker.hasWork) {
await promiseTracker.waitForCompletion()
return resolveAll(render, promiseTracker)
}
return renderResult
}
// And finally we can use it:
resolveAll(() => ReactDOM.renderToString(<App />), new PromiseTracker())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment