packages/material-ui-lab/src/internal/pickers/utils.ts/mergeRefs
export function mergeRefs<T>(refs: Array<React.Ref<T | null> | undefined>) {
  return (value: T) => {
    refs.forEach((ref) => {
      if (typeof ref === 'function') {
        ref(value);
      } else if (typeof ref === 'object' && ref != null) {
        // @ts-expect-error do not use MutableRefObject here for easier type inference from useRef
        ref.current = value;
      }
    });
  };
}