Skip to content

Commit

Permalink
Improve ts expect error comment
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Jul 31, 2024
1 parent eae30c4 commit 227a3e0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/mui-utils/src/getElementRef/getElementRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ export default function getElementRef(element: React.ReactElement<any>): React.R
if (!element || !React.isValidElement(element)) {
return null;
}

// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
return (element.props as any).propertyIsEnumerable('ref')
? (element.props as any).ref
: // @ts-expect-error child.ref is incompatible with types prior to React 19
: // @ts-expect-error element.ref is not included with ReactElement type, even though it exists
element.ref;
}

0 comments on commit 227a3e0

Please sign in to comment.