mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
20 lines
410 B
TypeScript
20 lines
410 B
TypeScript
import * as React from 'react';
|
|
import { fillRef } from '../ref';
|
|
|
|
function useCombinedRefs<T>(
|
|
...refs: Array<React.MutableRefObject<T> | ((instance: T) => void) | null>
|
|
) {
|
|
const targetRef = React.useRef<T>();
|
|
|
|
React.useEffect(() => {
|
|
refs.forEach(ref => {
|
|
if (!ref) return;
|
|
fillRef(ref, targetRef.current);
|
|
});
|
|
}, [refs]);
|
|
|
|
return targetRef;
|
|
}
|
|
|
|
export default useCombinedRefs;
|