Skip to content

Commit f7f4549

Browse files
committed
chore: apply mutation suggestions
1 parent f223828 commit f7f4549

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/clerk-js/src/ui/components/ApiKeys/ApiKeys.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { isClerkAPIResponseError } from '@clerk/shared/error';
22
import { useClerk, useOrganization, useUser } from '@clerk/shared/react';
33
import type { CreateAPIKeyParams } from '@clerk/shared/types';
44
import { lazy, useState } from 'react';
5+
import { useSWRConfig } from 'swr';
56
import useSWRMutation from 'swr/mutation';
67

78
import { useProtect } from '@/ui/common';
@@ -72,7 +73,14 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
7273
data: createdApiKey,
7374
trigger: createApiKey,
7475
isMutating,
75-
} = useSWRMutation(cacheKey, (_key, { arg }: { arg: CreateAPIKeyParams }) => clerk.apiKeys.create(arg));
76+
} = useSWRMutation(
77+
{
78+
...cacheKey,
79+
action: 'create',
80+
},
81+
(_key, { arg }: { arg: CreateAPIKeyParams }) => clerk.apiKeys.create(arg),
82+
);
83+
const { mutate: mutateApiKeys } = useSWRConfig();
7684
const { t } = useLocalizations();
7785
const [isRevokeModalOpen, setIsRevokeModalOpen] = useState(false);
7886
const [selectedApiKeyId, setSelectedApiKeyId] = useState('');
@@ -85,6 +93,7 @@ export const APIKeysPage = ({ subject, perPage, revokeModalRoot }: APIKeysPagePr
8593
...params,
8694
subject,
8795
});
96+
void mutateApiKeys(cacheKey);
8897
card.setError(undefined);
8998
setIsCopyModalOpen(true);
9099
} catch (err: any) {

0 commit comments

Comments
 (0)