Open shellscape opened 10 months ago
Thanks for your question @shellscape.
I have considered implementing a streaming - async - renderer before because JSX is so slow compared to string based template libraries like Handlebars. However, I've not had a reason to invest effort into this.
Because this library doesn't handle state I think any <Suspense>
implementation would be very basic - either always rendering the fallback or always waiting for its children to resolve. It's certainly possible to support this to avoid erroring if nothing else.
@i-like-robots we're currently using a mishmashed jsx renderer, with a significant portion based on hyperons. we've integrated Suspense
support here: https://github.com/shellscape/jsx-email/blob/afd9ca80fe1111e17796901f7bd6c0187c0a0de5/packages/jsx-email/src/render/jsx-to-string.ts#L93-L143
It works well with all of our testing and userland use. Hopefully that's helpful for hyperons.
Thank you @shellscape that's very interesting. And I'm really pleased to hear the code has been useful for more people 👍
I've added a very basic shim for the <Suspense>
component in #51
Longer term, I think supporting async components could be really interesting - not many templating languages do this well but it feels like it could be a fairly natural fit for JSX.
Hey thanks for the package! Any chance of getting
Suspense
andasync
support? For reference,hono
just added experimental support for that concept https://github.com/honojs/hono/blob/next/src/jsx/streaming.ts#L25