The full warning message:
[Vue warn]: Slot "default" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.
Nothing is broken and the functionality runs fine. I am just trying to clear this error.
Here is my code:
<template>
<ul class="flex" data-test-id="tab-wrapper">
<li
v-for="(tab, index) in tabs"
:key="index"
@click="currentTab = tab"
>
{{ tab }}
</li>
</ul>
<slot />
</template>
<script setup>
import { provide, ref, useSlots } from "vue";
const slots = useSlots();
const tabs = (slots.default && slots.default().map(tab => tab?.props?.title)) ?? [];
const currentTab = ref(tabs[0]);
provide("currentTab", currentTab);
</script>
It is my understanding that render() is implicit in the template, but I don't know how to implement the way I am using slots in the template v-for
.
Other questions that I have seen about this involve setup(props, context)
or actually rendering the template using render()
inside the script tag.
I'm brand new to Vue3/Composition API so I'm sure I did something wrong, but I'm having trouble figuring out exactly what. Any help is appreciated!