-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
🐛 BUG: React components using client:only
do not render children
#2265
Comments
I'm facing the same issue. After looking through the code, it seems to me that this is on purpose somehow.. This is the line where in the html gets rendered if the component is client:only.
Here it is slots.default, and it renders the html correctly.
So basically the children of the react component are used as a fallback in case the react component cannot be rendered. So i would say that the question here is, wether this is the intended behavior? |
Great followup, @tylergaw.
@natemoo-re, would you know what the recommendation is? |
@jonathantneal Probably for very simple use cases a simple workaround could be to embed your original component with children in a new "wrapper" component (without children, with client:only="react") which in turns embeds the original component with the original children. Easier to show than explain 😄 I had a similar issue and of course this is just a workaround, not the definitive and best solution. |
This is fixed in the latest version of Astro 🎉 |
this issue is also present with preact |
What version of
astro
are you using?0.21.13
What package manager are you using?
yarn
What operating system are you using?
Mac
Describe the Bug
Related issue #2215
When using
client:only
hydration of React components, no child components render.Given:
where
Parent
isThe containing
div
ofParent
will render, but not<div>I am child</div>
.Things I tried
I thought maybe the children also needed
client:only
, but that didn't change anything.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-agx2hb-lqeozd?file=src/pages/index.astro
The text was updated successfully, but these errors were encountered: