Open History to see the last commit
1'use client'
2β
3import { useSlotContext } from './SlotContext'
4β
5export interface ClientSlotProps {
6 slot: string
7 args: Array<unknown>
8}
9β
10export function ClientSlot({ slot, args }: ClientSlotProps) {
11 const ctx = useSlotContext()
12β
13 if (!ctx) {
14 throw new Error('ClientSlot must be rendered within SlotProvider')
15 }
16β
17 const impl = ctx.implementations[slot]
18β
19 // No implementation provided
20 if (impl === undefined) {
21 if (ctx.strict) {
22 throw new Error(`Missing slot implementation for "${slot}"`)
23 }
24 return null
25 }
26β
27 // For children slot or any non-function value, render directly
28 if (typeof impl !== 'function') {
29 return <>{impl}</>
30 }
31β
32 // Render function with args
33 return <>{impl(...args)}</>
34}