Skip to content

Commit

Permalink
fix: 🐛 prevent memory leak during component unmount
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejrybaniec committed Oct 30, 2020
1 parent 404872c commit 1092c8a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/js/app/components/ActionsMenu/ActionsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ type Props = {
onRemoveQuery: () => void;
/** Hide menu */
onHideMenu: () => void;
/** Visibility indicator */
isVisible?: boolean;
};

const ActionsMenu: FC<Props> = ({ isNewQuery, onRemoveQuery, onHideMenu }) => {
const ActionsMenu: FC<Props> = ({
isNewQuery,
isVisible,
onRemoveQuery,
onHideMenu,
}) => {
const dispatch = useDispatch();
const { t } = useTranslation();

Expand All @@ -46,13 +53,18 @@ const ActionsMenu: FC<Props> = ({ isNewQuery, onRemoveQuery, onHideMenu }) => {
const {
keenAnalysis: { config },
} = useContext(AppContext);

return (
<Container>
<DropdownMenu.Container>
<MutedText>{t('actions_menu.export_result')}</MutedText>
<ExportDataWrapper
onMouseEnter={() => !queryResults && showTooltip(true)}
onMouseLeave={() => tooltip && showTooltip(false)}
onMouseEnter={() => {
if (isVisible && !queryResults) {
showTooltip(true);
}
}}
onMouseLeave={() => tooltip && isVisible && showTooltip(false)}
>
<AnimatePresence>
{tooltip && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const BrowserQueryMenu: FC<Props> = ({ onEditQuery, onRemoveQuery }) => {
>
<ActionsMenu
isNewQuery={false}
isVisible={actionsMenu}
onHideMenu={() => setActionsMenuVisibility(false)}
onRemoveQuery={() => {
setActionsMenuVisibility(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const EditorNavigation: FC<Props> = ({ onSaveQuery }) => {
>
<ActionsMenu
isNewQuery={!exists}
isVisible={actionsMenu}
onHideMenu={() => setActionsMenuVisibility(false)}
onRemoveQuery={() => {
setActionsMenuVisibility(false);
Expand Down

0 comments on commit 1092c8a

Please sign in to comment.