@radix-ui/react-compose-refs
Advanced tools
Comparing version 1.1.1-rc.1 to 1.1.1-rc.2
@@ -8,3 +8,3 @@ import * as React from 'react'; | ||
*/ | ||
declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => () => void; | ||
declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => (() => void) | undefined; | ||
/** | ||
@@ -14,4 +14,4 @@ * A custom hook that composes multiple refs | ||
*/ | ||
declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => () => void; | ||
declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => (() => void) | undefined; | ||
export { composeRefs, useComposedRefs }; |
@@ -50,11 +50,13 @@ "use strict"; | ||
const cleanups = refs.map((ref) => setRef(ref, node)); | ||
return () => { | ||
cleanups.forEach((cleanup, i) => { | ||
if (typeof cleanup == "function") { | ||
cleanup(); | ||
} else { | ||
setRef(refs[i], null); | ||
} | ||
}); | ||
}; | ||
if (cleanups.some((c) => typeof c == "function")) { | ||
return () => { | ||
cleanups.forEach((cleanup, i) => { | ||
if (typeof cleanup == "function") { | ||
cleanup(); | ||
} else { | ||
setRef(refs[i], null); | ||
} | ||
}); | ||
}; | ||
} | ||
}; | ||
@@ -61,0 +63,0 @@ } |
{ | ||
"name": "@radix-ui/react-compose-refs", | ||
"version": "1.1.1-rc.1", | ||
"version": "1.1.1-rc.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9615
110