MCPcopy
hub / github.com/adobe/react-spectrum / useSlotId

Function useSlotId

packages/react-aria/src/utils/useId.ts:119–133  ·  view source on GitHub ↗
(depArray: ReadonlyArray<any> = [])

Source from the content-addressed store, hash-verified

117 * @param depArray - When to recalculate if the id is in the DOM.
118 */
119export function useSlotId(depArray: ReadonlyArray<any> = []): string {
120 let id = useId();
121 let [resolvedId, setResolvedId] = useValueEffect(id);
122 let updateId = useCallback(() => {
123 setResolvedId(function* () {
124 yield id;
125
126 yield document.getElementById(id) ? id : undefined;
127 });
128 }, [id, setResolvedId]);
129
130 useLayoutEffect(updateId, [id, updateId, ...depArray]);
131
132 return resolvedId;
133}

Callers 15

useCalendarBaseFunction · 0.90
useGridListSectionFunction · 0.90
useGridListItemFunction · 0.90
useFieldFunction · 0.90
useMenuItemFunction · 0.90
useOptionFunction · 0.90
useDialogFunction · 0.90
useToastFunction · 0.90
DropZone.tsxFile · 0.90
Slots.test.jsFile · 0.90
TrayHeaderWrapperFunction · 0.90
MenuItemFunction · 0.90

Calls 2

useValueEffectFunction · 0.90
useIdFunction · 0.85

Tested by

no test coverage detected