fix: edge case with slotted children (#2978)
This commit is contained in:
parent
dc6e89f0a3
commit
3f0bc5af57
2 changed files with 7 additions and 2 deletions
5
.changeset/flat-coats-crash.md
Normal file
5
.changeset/flat-coats-crash.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix edge case where default slots could be rendered too early for Astro components. Slots are now only rendered on demand.
|
|
@ -150,9 +150,8 @@ export async function renderComponent(
|
|||
slots: any = {}
|
||||
) {
|
||||
Component = await Component;
|
||||
const children = await renderSlot(result, slots?.default);
|
||||
|
||||
if (Component === Fragment) {
|
||||
const children = await renderSlot(result, slots?.default);
|
||||
if (children == null) {
|
||||
return children;
|
||||
}
|
||||
|
@ -197,6 +196,7 @@ Did you mean to add ${formatList(probableRendererNames.map((r) => '`' + r + '`')
|
|||
throw new Error(message);
|
||||
}
|
||||
|
||||
const children = await renderSlot(result, slots?.default);
|
||||
// Call the renderers `check` hook to see if any claim this component.
|
||||
let renderer: SSRLoadedRenderer | undefined;
|
||||
if (metadata.hydrate !== 'only') {
|
||||
|
|
Loading…
Reference in a new issue