@carbon/react
Version:
React components for the Carbon Design System
24 lines (22 loc) • 544 B
JavaScript
/**
* Copyright IBM Corp. 2016, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
//#region src/tools/mergeRefs.ts
/**
* @param refs Refs to merge.
* @returns Merged ref.
*/
const mergeRefs = (...refs) => {
return (value) => {
refs.forEach((ref) => {
if (!ref) return;
if (typeof ref === "function") ref(value);
else if (typeof ref === "object" && "current" in ref) ref.current = value;
});
};
};
//#endregion
export { mergeRefs };