MCPcopy Index your code
hub / github.com/adobe/react-spectrum / mergeIds

Function mergeIds

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

Source from the content-addressed store, hash-verified

91 * Different ids will trigger a side-effect and re-render components hooked up with `useId`.
92 */
93export function mergeIds(idA: string, idB: string): string {
94 if (idA === idB) {
95 return idA;
96 }
97
98 let setIdsA = idsUpdaterMap.get(idA);
99 if (setIdsA) {
100 setIdsA.forEach(ref => (ref.current = idB));
101 return idB;
102 }
103
104 let setIdsB = idsUpdaterMap.get(idB);
105 if (setIdsB) {
106 setIdsB.forEach(ref => (ref.current = idA));
107 return idA;
108 }
109
110 return idB;
111}
112
113/**
114 * Used to generate an id, and after render, check if that id is rendered so we know

Callers 2

mergePropsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected