Skip to content

Commit

Permalink
rename children to child
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Jul 7, 2024
1 parent 2f926cd commit 5bc21fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/mui-material/src/utils/getChildRef.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function getChildRef(children: React.ReactElement): React.Ref<any> | null;
export default function getChildRef(child: React.ReactElement): React.Ref<any> | null;
8 changes: 4 additions & 4 deletions packages/mui-material/src/utils/getChildRef.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';

export default function getChildRef(children) {
if (!children || !React.isValidElement(children) || React.Children.count(children) !== 1) {
export default function getChildRef(child) {
if (!child || !React.isValidElement(child) || React.Child.count(child) !== 1) {
return null;
}
// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in React 18
// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to child in React 18
// below check is to ensure 'ref' is accessible in both cases
return children.props.propertyIsEnumerable('ref') ? children.props.ref : children.ref;
return child.props.propertyIsEnumerable('ref') ? child.props.ref : child.ref;
}

0 comments on commit 5bc21fa

Please sign in to comment.