Replies: 1 comment 2 replies
-
This seems like a very reasonable change! Want to make a PR directly? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
Support async rendering for Solid JS.
Background & Motivation
The Solid JS renderer uses renderToString, not renderToStringAsync. It seems a little out of place, considering that:
renderToStaticMarkup
already appears to support async functions / returned promises@astrojs/image
provide async functions likegetImage()
that are not usable in sync-only Solid componentsExample
In my own project, I patched Astro Solid here: https://github.com/patdx/pmil.me/blob/33f26446c60456f8889402e2668f805f6ad229f6/.yarn/patches/%40astrojs-solid-js-npm-2.0.2-bccf2155a9.patch
And it worked quite nicely. Most notably, I was then able to build my own "async component" by using Suspense: https://github.com/patdx/pmil.me/blob/main/src/components/Image.tsx
The trickiest part of my experiment is that suspense boundaries and
createResource
calls seem to inject hydration scripts into the rendered HTML output, even for components that are not intended to hydrate. By wrapping the component in NoHydration and Suspense, it did not generate any unnecessary hydration scripts and it basically became an async component. I'm not sure if these components should be included by default or left up to users. Need to consider the impact on users of hydrated components too.Beta Was this translation helpful? Give feedback.
All reactions