withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
45.39k stars 2.37k forks source link

Render client framework twice #11376

Open ido-pluto opened 2 months ago

ido-pluto commented 2 months ago

Astro Info

Astro                    v4.11.3
Node                     v20.9.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

Chrome

Describe the Bug

If I render a child twice that contains a client framework (react), and does not use all the renders, it will output nothing.

---
await Astro.slots.render('default');
const content2 = await Astro.slots.render('default');
---
<Fragment set:html={content2} />

For this component

---
import { ReactComponent } from './ReactComponent.jsx';
---

<li class='link-card'>
    <ReactComponent client:only="react"/>
</li>

The result is: image (The client framework does not render at all)

What's the expected result?

image Client framework render

Link to Minimal Reproducible Example

https://github.com/ido-pluto/astro-render-bug/tree/main

Participation

bluwy commented 1 month ago

Somewhat related https://github.com/withastro/astro/issues/11079, calling Astro.slots.render() multiple times has been problematic.