UNPKG

@ark-ui/react

Version:

A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.

25 lines (23 loc) 490 B
function composeRefs(...refs) { return (node) => { const cleanUps = []; for (const ref of refs) { if (typeof ref === "function") { const cb = ref(node); if (typeof cb === "function") { cleanUps.push(cb); } } else if (ref) { ref.current = node; } } if (cleanUps.length) { return () => { for (const cleanUp of cleanUps) { cleanUp(); } }; } }; } export { composeRefs };