UNPKG

rsuite

Version:

A suite of react components

17 lines (16 loc) 410 B
'use client'; const toFnRef = ref => !ref || typeof ref === 'function' ? ref : value => { ref.current = value; }; /** * Merges two React refs into a single ref callback. */ export function mergeRefs(refA, refB) { const a = toFnRef(refA); const b = toFnRef(refB); return value => { if (typeof a === 'function') a(value); if (typeof b === 'function') b(value); }; } export default mergeRefs;