Skip to content

Commit 9767107

Browse files
committed
move logic
1 parent 4ca3a6d commit 9767107

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

packages/mui-material/src/utils/getChildRef.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/mui-utils/src/getReactNodeRef/getReactNodeRef.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ import * as React from 'react';
88
* @returns React.Ref<any> | null
99
*/
1010
export default function getReactNodeRef(element: React.ReactNode): React.Ref<any> | null {
11-
if (!element || !React.isValidElement(element)) {
12-
return null;
13-
}
14-
1511
// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
16-
return (element.props as any).propertyIsEnumerable('ref')
17-
? (element.props as any).ref
12+
return (element as any)!.props.propertyIsEnumerable('ref')
13+
? (element as any)!.props.ref
1814
: // @ts-expect-error element.ref is not included in the ReactElement type
1915
// We cannot check for it, but isValidElement is true at this point
2016
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189

0 commit comments

Comments
 (0)