/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ import type {Ref} from 'react'; export function mergeRefs(...refs: Ref[]): (value: null | T) => void { return value => { for (const ref of refs) { if (typeof ref === 'function') { ref(value); } else if (ref != null) { ref.current = value; } } }; }