diff --git a/docs/data/material/components/menus/UnstyledMenuPopup.js b/docs/data/material/components/menus/UnstyledMenuPopup.js
index 393e603d4a9779..adf4d09d8d1b99 100644
--- a/docs/data/material/components/menus/UnstyledMenuPopup.js
+++ b/docs/data/material/components/menus/UnstyledMenuPopup.js
@@ -79,10 +79,11 @@ const Popper = styled(PopperUnstyled)`
`;
function MenuWrapper(props) {
- const { children, contentRef, label } = props;
+ const { children, label } = props;
const [isOpen, setOpen] = React.useState(false);
const buttonRef = React.useRef(null);
+ const contentRef = React.useRef(null);
const close = () => setOpen(false);
@@ -106,7 +107,7 @@ function MenuWrapper(props) {
>
{isOpen && (
setOpen(false)}>
- {children?.(close)}
+ {children?.(close, contentRef)}
)}
@@ -116,27 +117,13 @@ function MenuWrapper(props) {
MenuWrapper.propTypes = {
children: PropTypes.func.isRequired,
- contentRef: PropTypes.shape({
- current: function (props, propName) {
- if (props[propName] == null) {
- return null;
- } else if (
- typeof props[propName] !== 'object' ||
- props[propName].nodeType !== 1
- ) {
- return new Error("Expected prop '" + propName + "' to be of type Element");
- }
- },
- }).isRequired,
label: PropTypes.string,
};
export default function UnstyledMenuPopup() {
- const contentRef = React.useRef(null);
-
return (
-
- {(close) => (
+
+ {(close, contentRef) => (
close()}>English
close()}>中文
diff --git a/docs/data/material/components/menus/UnstyledMenuPopup.tsx b/docs/data/material/components/menus/UnstyledMenuPopup.tsx
index d4791771eaa9dd..265be24032a57b 100644
--- a/docs/data/material/components/menus/UnstyledMenuPopup.tsx
+++ b/docs/data/material/components/menus/UnstyledMenuPopup.tsx
@@ -78,16 +78,19 @@ const Popper = styled(PopperUnstyled)`
`;
interface MenuWrapperProps {
- contentRef: React.RefObject;
- children: (close: () => void) => JSX.Element;
+ children: (
+ close: () => void,
+ contentRef: React.RefObject,
+ ) => JSX.Element;
label?: string;
}
function MenuWrapper(props: MenuWrapperProps) {
- const { children, contentRef, label } = props;
+ const { children, label } = props;
const [isOpen, setOpen] = React.useState(false);
const buttonRef = React.useRef(null);
+ const contentRef = React.useRef(null);
const close = () => setOpen(false);
@@ -111,7 +114,7 @@ function MenuWrapper(props: MenuWrapperProps) {
>
{isOpen && (
setOpen(false)}>
- {children?.(close)}
+ {children?.(close, contentRef)}
)}
@@ -120,11 +123,9 @@ function MenuWrapper(props: MenuWrapperProps) {
}
export default function UnstyledMenuPopup() {
- const contentRef = React.useRef(null);
-
return (
-
- {(close) => (
+
+ {(close, contentRef) => (
close()}>English
close()}>中文
diff --git a/docs/data/material/components/menus/UnstyledMenuPopup.tsx.preview b/docs/data/material/components/menus/UnstyledMenuPopup.tsx.preview
index c0797bed3baae3..500e881833e905 100644
--- a/docs/data/material/components/menus/UnstyledMenuPopup.tsx.preview
+++ b/docs/data/material/components/menus/UnstyledMenuPopup.tsx.preview
@@ -1,5 +1,5 @@
-
- {(close) => (
+
+ {(close, contentRef) => (
close()}>English
close()}>中文