Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

remove pendingOpenUnmount

Pedro Ladeiraeed4ab5c04cc
diff --git a/apps/web/ui/partners/partner-advanced-settings-modal.tsx b/apps/web/ui/partners/partner-advanced-settings-modal.tsx
index 381c419f04..3b4c342ab8 100644
--- a/apps/web/ui/partners/partner-advanced-settings-modal.tsx
+++ b/apps/web/ui/partners/partner-advanced-settings-modal.tsx
@@ -282,11 +282,7 @@ export function usePartnerAdvancedSettingsModal({
partner={partner}
/>
);
- }, [
- showPartnerAdvancedSettingsModal,
- setShowPartnerAdvancedSettingsModal,
- partner,
- ]);
+ }, [showPartnerAdvancedSettingsModal, setShowPartnerAdvancedSettingsModal]);
return useMemo(
() => ({
diff --git a/packages/ui/src/modal.tsx b/packages/ui/src/modal.tsx
index 6f69fa3c1b..d80560391c 100644
--- a/packages/ui/src/modal.tsx
+++ b/packages/ui/src/modal.tsx
@@ -4,58 +4,10 @@ import { cn } from "@dub/utils";
import * as Dialog from "@radix-ui/react-dialog";
import * as VisuallyHidden from "@radix-ui/react-visually-hidden";
import { useRouter } from "next/navigation";
-import {
- ComponentProps,
- Dispatch,
- SetStateAction,
- useEffect,
- useRef,
-} from "react";
+import { ComponentProps, Dispatch, SetStateAction } from "react";
import { Drawer } from "vaul";
import { useMediaQuery } from "./hooks";
-// Dev-only detector for modal remount bugs: an open Modal unmounting while
-// another mounts open in the same commit means its element type changed
-// (unstable hook dep) and any user state in it was lost
-let pendingOpenUnmount: unknown = null;
-
-function useWarnOnRemountWhileOpen(showModal?: boolean) {
- // Per-instance token so Strict Mode's same-instance setup/cleanup/setup
- // cycle doesn't register as a remount
- const instance = useRef({});
- const showModalRef = useRef(showModal);
-
- useEffect(() => {
- showModalRef.current = showModal;
- });
-
- useEffect(() => {
- if (process.env.NODE_ENV !== "development") return;
-
- if (
- showModalRef.current &&
- pendingOpenUnmount &&
- pendingOpenUnmount !== instance.current
- ) {
- pendingOpenUnmount = null;
- console.warn(
- "[Modal] remounted while open — the modal's element type changed mid-session (unstable hook dep?) and any user state in it was lost.",
- );
- }
-
- return () => {
- if (showModalRef.current) {
- pendingOpenUnmount = instance.current;
- queueMicrotask(() => {
- if (pendingOpenUnmount === instance.current) {
- pendingOpenUnmount = null;
- }
- });
- }
- };
- }, []);
-}
-
export function Modal({
children,
className,
@@ -77,8 +29,6 @@ export function Modal({
}) {
const router = useRouter();
- useWarnOnRemountWhileOpen(showModal);
-
const closeModal = ({ dragged }: { dragged?: boolean } = {}) => {
if (preventDefaultClose && !dragged) {
return;