Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Aug 9, 2024
1 parent 9767107 commit 348814b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/mui-utils/src/getReactNodeRef/getReactNodeRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import * as React from 'react';
*/
export default function getReactNodeRef(element: React.ReactNode): React.Ref<any> | null {
// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
return (element as any)!.props.propertyIsEnumerable('ref')
? (element as any)!.props.ref
return (element as any)?.props?.propertyIsEnumerable('ref')
? (element as any)?.props.ref
: // @ts-expect-error element.ref is not included in the ReactElement type
// We cannot check for it, but isValidElement is true at this point
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
Expand Down

0 comments on commit 348814b

Please sign in to comment.