import { isFunction } from '@sniptt/guards'; import { MutableRefObject, Ref } from 'react'; import { isDefined } from 'twenty-shared'; export const combineRefs = (...refs: (Ref | undefined)[]) => { return (node: T) => { for (const ref of refs) { if (isFunction(ref)) { ref(node); } else if (isDefined(ref) && 'current' in ref) { (ref as MutableRefObject).current = node; } } }; };