Skip to content

Commit

Permalink
Made close function optional (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexShukel authored Jun 14, 2022
1 parent 1722c4b commit 4a84c89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/hooks/useCloseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isDefaultPopup } from '../types/DefaultPopup';
import { usePopupIdentifier } from '../utils/PopupIdentifierContext';

export const useCloseHandler = (
close: () => void | Promise<void>
close?: () => void | Promise<void>
): (() => void) => {
const { getPopup, unmount } = usePopupsContext();

Expand All @@ -23,7 +23,9 @@ export const useCloseHandler = (
throw new Error(CLOSE_HANDLER_BAD_USE);
}

popup.setCloseHandler(close);
if (close) {
popup.setCloseHandler(close);
}
}, [popupIdentifier, close, getPopup]);

return unmountPopup;
Expand Down

0 comments on commit 4a84c89

Please sign in to comment.