From c5a78ea1542ffe8b202b807f3d0516cfc4eb2960 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Mon, 20 Jan 2025 07:47:51 +0100 Subject: [PATCH] fix(nuxt): wrap slot with `h()` in ClientOnly (#30664) --- packages/nuxt/src/app/components/client-only.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nuxt/src/app/components/client-only.ts b/packages/nuxt/src/app/components/client-only.ts index 46149f6a79..b3c9aeb3a1 100644 --- a/packages/nuxt/src/app/components/client-only.ts +++ b/packages/nuxt/src/app/components/client-only.ts @@ -14,7 +14,7 @@ export default defineComponent({ inheritAttrs: false, props: ['fallback', 'placeholder', 'placeholderTag', 'fallbackTag'], - setup (_, { slots, attrs }) { + setup (props, { slots, attrs }) { const mounted = ref(false) onMounted(() => { mounted.value = true }) // Bail out of checking for pages/layouts as they might be included under `` 🤷‍♂️ @@ -24,10 +24,10 @@ export default defineComponent({ nuxtApp._isNuxtLayoutUsed = true } provide(clientOnlySymbol, true) - return (props: any) => { + return () => { if (mounted.value) { return slots.default?.() } const slot = slots.fallback || slots.placeholder - if (slot) { return slot() } + if (slot) { return h(slot) } const fallbackStr = props.fallback || props.placeholder || '' const fallbackTag = props.fallbackTag || props.placeholderTag || 'span' return createElementBlock(fallbackTag, attrs, fallbackStr)