import * as React from 'react'; import { ConfigContext } from '../config-provider'; export interface BaseProps { prefixCls?: string; style?: React.CSSProperties; } /* istanbul ignore next */ export default function genPurePanel(Component: any) { return function PurePanel(props: ComponentProps) { const { prefixCls: customizePrefixCls, style } = props; const holderRef = React.useRef(null); const [popupHeight, setPopupHeight] = React.useState(0); const [open, setOpen] = React.useState(false); const { getPrefixCls } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('select', customizePrefixCls); React.useEffect(() => { // We do not care about ssr setOpen(true); if (typeof ResizeObserver !== 'undefined') { const resizeObserver = new ResizeObserver(entries => { const element: HTMLDivElement = entries[0].target as any; setPopupHeight(element.offsetHeight + 8); }); const interval = setInterval(() => { const popup = holderRef.current?.querySelector(`.${prefixCls}-dropdown`); if (popup) { clearInterval(interval); resizeObserver.observe(popup); } }, 10); return () => { clearInterval(interval); resizeObserver.disconnect(); }; } }, []); return (
holderRef.current!} />
); } as typeof Component; }