-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improving performance through streaming #66
Comments
Thanks for opening an issue. I'm time poor right now. Though, I'd be interested in what this would/could look like and how we'd integrate (optionally) |
Right now I'm experimenting with kind of skipping vision altogether by hooking up
module.exports = function(view, dataFromController) {
const data = extend(someDataWithLocaleOrOtherServerStuff, dataFromController);
const Component = require(`../components/${view}.js`);
const componentRenderer = render(<Component {...data} />);
const responseRenderer = template`
<html>
<head>
[...]
<div id="app-mount">${componentRenderer}</div>
[...]
<script id="app-state">
window.state = ${() => JSON.stringify(data)}
document.querySelector("#app-mount").setAttribute("data-react-checksum", "${componentRenderer.checksum()}")
</script>
<script src="/scripts/client.js"></script>
</body>
</html>
`;
const stream = responseRenderer.toStream();
this(stream);
}
reply.renderReact('home', {
title: 'Home',
records: someDatabaseResult,
}); Which feels wrong but works surprisingly well. |
@tom2strobl I'd love for |
React v16 supports streaming: Even though streaming isn't totally general purpose (there are some gotchas), I'm much more inclined to try incorporating a streaming API in Is |
@wswoodruff to be honest we moved away from hapi directly serving client markup at all. We run next.js and it's |
@tom2strobl Cool! I haven't delved too much into SSR for React yet, seems like a great setup! |
This is obviously not an issue, but a possible enhancement: Currently we compile the htmlOutput and then send it over the wire, we could instead leverage streaming the contents down by using https://github.com/FormidableLabs/rapscallion, which imho nailed it.
The text was updated successfully, but these errors were encountered: