Skip to content

Commit

Permalink
move logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Aug 9, 2024
1 parent 4ca3a6d commit 9767107
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
5 changes: 0 additions & 5 deletions packages/mui-material/src/utils/getChildRef.js

This file was deleted.

8 changes: 2 additions & 6 deletions packages/mui-utils/src/getReactNodeRef/getReactNodeRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ import * as React from 'react';
* @returns React.Ref<any> | null
*/
export default function getReactNodeRef(element: React.ReactNode): React.Ref<any> | null {
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
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 9767107

Please sign in to comment.