@primer/react
Version:
An implementation of GitHub's Primer Design System using React
18 lines (15 loc) • 432 B
JavaScript
import { useCallback } from 'react';
function useMergedRefs(...refs) {
return useCallback(instance => {
for (const ref of refs) {
if (typeof ref === 'function') {
ref(instance);
} else if (ref) {
ref.current = instance;
}
}
// eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/exhaustive-deps
}, refs);
}
export { useMergedRefs };