react-native-a11y
Version:
Improvements of a11y for ReactNative, this library improve work with reader and keyboard focus and reader in general.
13 lines (11 loc) • 383 B
text/typescript
import type { Ref, RefCallback } from 'react';
export const combineRefs =
<T>(...refs: Ref<T>[]): RefCallback<T> =>
(component) =>
refs.forEach((item) => {
if (typeof item === 'function') {
item(component);
} else if (item !== null && item?.current !== undefined) {
(item as React.MutableRefObject<T | null>).current = component;
}
});