Migrate to a monorepo structure (#2909)
This commit is contained in:
14
packages/twenty-front/src/hooks/useCombinedRefs.ts
Normal file
14
packages/twenty-front/src/hooks/useCombinedRefs.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import React, { Ref, RefCallback } from 'react';
|
||||
import { isFunction } from '@sniptt/guards';
|
||||
|
||||
export const useCombinedRefs =
|
||||
<T>(...refs: (Ref<T> | undefined)[]): RefCallback<T> =>
|
||||
(node: T) => {
|
||||
for (const ref of refs) {
|
||||
if (isFunction(ref)) {
|
||||
ref(node);
|
||||
} else if (ref !== null && ref !== undefined) {
|
||||
(ref as React.MutableRefObject<T | null>).current = node;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user