Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 497x 978x 2926x 724x 2202x 1112x 1112x 1090x 1090x 1090x | /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
*/
import * as React from 'react';
export default function mergeRefs(
...args: $ReadOnlyArray<React.ElementRef<any>>
): (node: HTMLElement | null) => void {
return function forwardRef(node: HTMLElement | null) {
args.forEach((ref: React.ElementRef<any>) => {
if (ref == null) {
return;
}
if (typeof ref === 'function') {
ref(node);
return;
}
Eif (typeof ref === 'object') {
ref.current = node;
return;
}
console.error(
`mergeRefs cannot handle Refs of type boolean, number or string, received ref ${String(
ref
)}`
);
});
};
}
|