Skip to content

Commit

Permalink
fix(Menu): 修复 Menu 使用 React.StrictMode 报错 (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuilanxin authored Apr 11, 2022
1 parent 1d6ea8d commit a62e924
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions packages/react-menu/src/SubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ export const SubMenu = React.forwardRef(function <Tag extends TagType = 'a'>(
}
}
function onExit(node: HTMLElement) {
node.style.height = `${node.scrollHeight}px`;
node && (node.style.height = `${node.scrollHeight}px`);
setIsOpen(false);
}
function onExiting(node: HTMLElement) {
node.style.height = '0px';
node && (node.style.height = '0px');
}
function onEnter(node: HTMLElement) {
node.style.height = '1px';
node && (node.style.height = '1px');
setIsOpen(true);
}
function onEntering(node: HTMLElement) {
node.style.height = `${node.scrollHeight}px`;
node && (node.style.height = `${node.scrollHeight}px`);
}
function onEntered(node: HTMLElement) {
node.style.height = 'initial';
node && (node.style.height = 'initial');
}

if (!collapse) {
Expand Down
3 changes: 2 additions & 1 deletion packages/react-overlay/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function Overlay(props: OverlayProps) {
// const [isOpen, setIsOpen] = useState(props.isOpen || false);
const [visible, setVisible] = useState(false);
const container = useRef<HTMLDivElement>(null);
const overlay = useRef<HTMLDivElement>(null);
const overlay = useRef(null);
useEffect(() => {
if (isOpen !== props.isOpen && props.isOpen) {
setVisible(true);
Expand Down Expand Up @@ -138,6 +138,7 @@ export default function Overlay(props: OverlayProps) {
onEntered={onOpened}
onExiting={onClosing}
onExited={handleClosed}
nodeRef={overlay}
{...otherProps}
>
{(status) => {
Expand Down

0 comments on commit a62e924

Please sign in to comment.