Skip to content

Commit

Permalink
Using if clause instead of lodaashGet
Browse files Browse the repository at this point in the history
Signed-off-by: Tsaqif <[email protected]>
  • Loading branch information
tsa321 committed Oct 16, 2023
1 parent c58c53e commit 2245a7e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/PopoverProvider/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';

const propTypes = {
children: PropTypes.node.isRequired,
Expand All @@ -25,7 +24,9 @@ function PopoverContextProvider(props) {
}

activePopoverRef.current.close();
lodashGet(activePopoverRef, 'current.onCloseCallback', () => {})();
if (activePopoverRef && activePopoverRef.current && activePopoverRef.current.onCloseCallback) {
activePopoverRef.current.onCloseCallback();
}
activePopoverRef.current = null;
setIsOpen(false);
}, []);
Expand Down Expand Up @@ -109,7 +110,9 @@ function PopoverContextProvider(props) {
closePopover(activePopoverRef.current.anchorRef);
}
activePopoverRef.current = popoverParams;
lodashGet(activePopoverRef, 'current.onOpenCallback', () => {})();
if (popoverParams && popoverParams.onOpenCallback) {
popoverParams.onOpenCallback();
}
setIsOpen(true);
},
[closePopover],
Expand Down

0 comments on commit 2245a7e

Please sign in to comment.