Forwarded slots don't receive props
Version
3.1.2
Reproduction link
Steps to reproduce
check reproduction
What is expected?
option slot in app.vue should receive props from Child component and render foo+foo
What is actually happening?
Forwarded slots don't receive props from Child component. Take a look at the generated code for Parent component.
default: _withCtx(() => [
_renderSlot(_ctx.$slots, "option")
]),
There's a workaround for this issue but I wonder if can be avoided?
<Child>
<template #default="props">
<slot v-bind="props" name="option"></slot>
</template>
</Child>
// Edit: hmm I see it currently works like in vue 2, so I assume changing this would be a breaking change?
No, it can't be avoided, and is no workaround - this is how slots work. In this specific case, you can make it a tad more succinct as Child
only has one default slot:
<script setup>
import Child from './Child.vue'
</script>
<template>
<Child v-slot="{ value }">
<slot name="option" :value="value"></slot>
</Child>
</template>