MCPcopy Create free account
hub / github.com/adobe/react-spectrum / mergeIds

Function mergeIds

packages/react-aria/src/utils/useId.ts:109–127  ·  view source on GitHub ↗
(idA: string, idB: string)

Source from the content-addressed store, hash-verified

107 * Different ids will trigger a side-effect and re-render components hooked up with `useId`.
108 */
109export function mergeIds(idA: string, idB: string): string {
110 if (idA === idB) {
111 return idA;
112 }
113
114 let setIdsA = idsUpdaterMap.get(idA);
115 if (setIdsA) {
116 setIdsA.forEach(ref => (ref.current = idB));
117 return idB;
118 }
119
120 let setIdsB = idsUpdaterMap.get(idB);
121 if (setIdsB) {
122 setIdsB.forEach(ref => (ref.current = idA));
123 return idA;
124 }
125
126 return idB;
127}
128
129/**
130 * Used to generate an id, and after render, check if that id is rendered so we know

Callers 3

mergePropsFunction · 0.90
useId.test.jsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected