Skip to content

Commit

Permalink
Fix useModal hook placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Sep 10, 2024
1 parent 09c9882 commit 5ac60e3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions shared/common/hooks/useModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ export function ModalProvider({children}: PropsWithChildren<{}>) {
);
}

const modalPlaceholder = <></>;

export function useModal(): {
modal: JSX.Element | null;
openModal: (modal: JSX.Element | null, transition?: boolean) => () => void;
Expand All @@ -109,6 +107,7 @@ export function useModal(modal?: JSX.Element): {
| ((transition?: boolean) => () => void);
} {
const ctx = useContext(modalContext);
const placeholder = useRef(<></>);

if (!modal) {
return {
Expand All @@ -119,11 +118,11 @@ export function useModal(modal?: JSX.Element): {

return {
modal:
ctx.modal === modalPlaceholder
ctx.modal === placeholder.current
? createPortal(modal, document.getElementById("modal_target")!)
: null,
openModal: (transition?: boolean) =>
ctx.openModal(modalPlaceholder, transition),
ctx.openModal(placeholder.current, transition),
};
}

Expand Down

0 comments on commit 5ac60e3

Please sign in to comment.