Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Refactor domain check mutation to use ref object

Richie McIlroy4a89670e5e98
diff --git a/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/CustomDomainDialog.tsx b/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/CustomDomainDialog.tsx
index 475f92fb8..0bd00bb33 100644
--- a/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/CustomDomainDialog.tsx
+++ b/apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/CustomDomainDialog.tsx
@@ -138,8 +138,11 @@ const CustomDomainDialog = ({
const router = useRouter();
const dialogRef = useRef<HTMLDivElement | null>(null);
const confettiRef = useRef<ConfettiRef>(null);
-
const pollInterval = useRef<NodeJS.Timeout | undefined>(undefined);
+ const checkDomainMutationRef = useRef<{
+ mutate: (args: { orgId: string; showToasts: boolean }) => void;
+ isPending: boolean;
+ } | null>(null);
const updateDomainMutation = useMutation({
mutationFn: async ({
@@ -218,6 +221,11 @@ const CustomDomainDialog = ({
},
});
+ checkDomainMutationRef.current = {
+ mutate: checkDomainMutation.mutate,
+ isPending: checkDomainMutation.isPending,
+ };
+
const [stepState, dispatch] = useReducer(stepReducer, {
currentIndex: 0,
totalSteps: STEP_CONFIGS.length,
@@ -267,7 +275,7 @@ const CustomDomainDialog = ({
)
return;
- checkDomainMutation.mutate({
+ checkDomainMutationRef.current?.mutate({
orgId: activeOrganization.organization.id,
showToasts,
});
@@ -275,7 +283,6 @@ const CustomDomainDialog = ({
[
activeOrganization?.organization.id,
activeOrganization?.organization.customDomain,
- checkDomainMutation,
],
);