Skip to main content

useSlot()

useSlot(): [RefCallback<Element>, boolean]

Detects whether a slot has been utilized

Example: Parent component implements RAC Provider, with a slotted context Child component implements slot prop matching provided slot in context Parent is able to see that the slot has been fulfilled

Copied from RAC: https://github.com/adobe/react-spectrum/blob/main/packages/react-aria-components/src/utils.tsx#L213 Due to not being exported, but quite handy

Returns

[RefCallback<Element>, boolean]