Skip to content

Commit f7fbcca

Browse files
committed
Add error boundaries for modals
Modals are self contained, so if there is an error in one it does not have to bring the whole application down with it.
1 parent eb5721f commit f7fbcca

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/components/shared/modals/Modal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useTranslation } from "react-i18next";
1212
import ButtonLikeAnchor from "../ButtonLikeAnchor";
1313
import { FocusTrap } from "focus-trap-react";
1414
import { LuX } from "react-icons/lu";
15+
import { ErrorBoundary } from "react-error-boundary";
1516

1617
export type ModalProps = {
1718
open?: boolean;
@@ -88,8 +89,13 @@ export const Modal = forwardRef<ModalHandle, PropsWithChildren<ModalProps>>(
8889
{header}
8990
</h2>
9091
</header>
91-
92+
<ErrorBoundary fallback={
93+
<div className="about">
94+
Something went wrong. Please close the modal and try again.
95+
</div>
96+
}>
9297
{children}
98+
</ErrorBoundary>
9399
</section>
94100
</div>
95101
</FocusTrap>,

0 commit comments

Comments
 (0)