UNPKG

react-native-keyboard-controller

Version:

Keyboard manager which works in identical way on both iOS and Android

23 lines (18 loc) 498 B
import { useCallback } from "react"; import type { Ref, RefCallback } from "react"; const useCombinedRef = <T>(...refs: Ref<T>[]): RefCallback<T> => { return useCallback((value: T | null) => { for (const ref of refs) { if (!ref) { continue; } if (typeof ref === "function") { ref(value); } else { ref.current = value; } } // eslint-disable-next-line react-compiler/react-compiler }, refs); }; export default useCombinedRef;