diff --git a/packages/mui-utils/src/getReactElementRef/getReactElementRef.ts b/packages/mui-utils/src/getReactElementRef/getReactElementRef.ts index 83620d496676a0..94dedd0548a54f 100644 --- a/packages/mui-utils/src/getReactElementRef/getReactElementRef.ts +++ b/packages/mui-utils/src/getReactElementRef/getReactElementRef.ts @@ -5,9 +5,11 @@ import * as React from 'react'; * It will throw runtime error if the element is not a valid React element. * * @param element React.ReactElement - * @returns React.Ref | null + * @returns React.Ref | null | undefined */ -export default function getReactElementRef(element: React.ReactElement): React.Ref | null { +export default function getReactElementRef( + element: React.ReactElement, +): React.Ref | null | undefined { const reactMajorVersion = parseInt(React.version.split('.')[0], 10); // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions