Consider this Vue 3 renderless component using the Composition API. What will be rendered in the parent component?
<template> <slot :count="count" /> </template> <script setup> import { ref } from 'vue' const count = ref(0) setInterval(() => { count.value++ }, 1000) </script>
Think about what a renderless component does with slots and reactive data.
The component itself renders nothing except the slot. The slot receives the reactive count prop, so the parent can display it. The component does not render any visible output by itself.
Given this renderless component code, what will be the value of count after 3 seconds?
<script setup> import { ref } from 'vue' const count = ref(0) setInterval(() => { count.value++ }, 1000) </script>
Count increments every 1000 milliseconds starting from 0.
The setInterval runs every 1 second, increasing count by 1. After 3 seconds, count will be 3.
Identify the correct syntax to pass reactive count to a default slot in a renderless component.
<template> <!-- Choose the correct slot binding --> </template> <script setup> import { ref } from 'vue' const count = ref(0) </script>
Remember how to bind reactive refs to slots in Vue 3.
Using :count="count" passes the reactive ref itself, allowing the parent to access count.value. Passing count.value directly would pass a primitive, losing reactivity.
This renderless component passes count to a slot, but the parent does not see updates. Why?
<template> <slot :count="count" /> </template> <script setup> import { ref } from 'vue' const count = 0 setInterval(() => { count++ }, 1000) </script>
Check how count is declared and updated.
count is a plain number, not a reactive ref. Incrementing it does not notify Vue to update the slot content. Using ref(0) makes it reactive.
Choose the best explanation for why developers use renderless components.
Think about how renderless components help reuse logic.
Renderless components provide reusable logic and state but delegate rendering to the parent via slots. This allows flexible UI design while sharing behavior.