3 ms·
Note that React doesn't do streaming HTML in the traditional sense. You can't send out initial HTML while you wait on an API response, for example. Instead only
by MatthewPhillips 9y ago
Note that React doesn't do streaming HTML in the traditional sense. You can't send out initial HTML while you wait on an API response, for example. Instead only the serializer is streaming. Your app renders to a VNode synchronously and then the serializer traverses the VNode, synchronously, and streams the strings out as it goes. This is why streaming is only a little bit better in these numbers.
If/when React gets real streaming it will compete better with traditional templating engines, most of which don't do streaming. If you use Node.js and want a traditional templating engine that uses JS template literals and does do streaming, check out my project: https://github.com/matthewp/flora https://github.com/matthewp/flora
- bringking 9y agoReact 16 supports streaming! https://reactjs.org/blog/2017/09/26/react-v16.0.html#better-server-side-rendering https://reactjs.org/blog/2017/09/26/react-v16.0.html#better-...
- bringking 9y agoOh sorry I should read better! Sorry
- styfle 9y agoI believe you can stream the <head> while still waiting for any react components to render like so: https://github.com/styfle/react-server-example-tsx/blob/4586f3431b4bfd424179da3aad2c6adbddb0de10/src/server.tsx#L22 https://github.com/styfle/react-server-example-tsx/blob/4586...
- MatthewPhillips 9y agoOf course, you can stream parts of your page that you don't use React. That should be obvious. :)