all slots end up in default slot when mixing TSX and SFC #10690
-
Hello everyone, I feel sorry to be asking this question but I'm afraid I can't find any instructions how to use named slots with JSX in the docs. Context:We're in the middle of an effort to move from JSX files ( My issue:I can't figure out how to make use of named slots that are defined inside vue files. <script setup></script>
<template>
<div>
<h2>Child</h2>
<span style="color: orange">
<slot name="default"></slot>
</span>
<span style="color: blue">
<slot name="foo"></slot>
</span>
</div>
</template> and my parent import { defineComponent } from 'vue';
import Child from './Child.vue';
export const App = defineComponent({
setup() {
return () => (
<Child>
<p slot="foo">I am in the foo slot</p>
<p slot="default">Here is the default</p>
</Child>
);
},
}); but even though I'm passing the different I just can't figure this out. Please help! Reproduction:I'm happy to provide you with a minimal reproduction: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
App.tsx component is not using proper JSX/TSX syntax. Here is working example > https://stackblitz.com/edit/vue3-tsx-vc8vsd?file=src%2FApp.tsx Reference: https://github.com/vuejs/babel-plugin-jsx?tab=readme-ov-file#slot |
Beta Was this translation helpful? Give feedback.
-
https://vuejs.org/guide/extras/render-function.html#passing-slots |
Beta Was this translation helpful? Give feedback.
App.tsx component is not using proper JSX/TSX syntax. Here is working example > https://stackblitz.com/edit/vue3-tsx-vc8vsd?file=src%2FApp.tsx
Reference: https://github.com/vuejs/babel-plugin-jsx?tab=readme-ov-file#slot