4 ms·
Just for clarification, React 16 does not support streaming, at least not in any way that is meaningful. React 16 has an API that gives you a Readable stream, b
by MatthewPhillips 9y ago
Just for clarification, React 16 does not support streaming, at least not in any way that is meaningful. React 16 has an API that gives you a Readable stream, but this stream doesn't provide HTML in chunks. It provides it all-at-once exactly like renderToString does.
What you really want with streaming is whenever rendering is blocked by something asynchronous, like a database request, that whatever HTML is finished can be flushed out. React could support real streaming in the future, but would likely require some new API.
Anyways, the sentence from the article "start sending bytes to the client faster" isn't factually true, it doesn't send it out any faster than renderToString would.
- spicyj 9y agoYou don't need to wait for the CPU time of all components to complete before the first bytes are available. When we render an HTML element, we now emit the opening tag before processing the children. People have seen benefits in practice from this. Our new architecture makes it easier to implement the type of async data fetching you describe and we'd like to add it in the future.
- MatthewPhillips 9y agoIf rendering blocks the CPU to such a degree that this helps get bytes out faster, then you have a much bigger issue to deal with.
- abiox 9y agothis seems like hasty generalization.
- PKop 9y agoThis comes later when the mentioned async rendering feature is available right?