Skip to content

Commit 62692cb

Browse files
authored
fix(clerk-js): Always revalidate checkout checkout when drawer opens (#5798)
1 parent 1b29288 commit 62692cb

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.changeset/mighty-years-learn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Always revalidate when checkout drawer opens

packages/clerk-js/src/ui/components/Checkout/CheckoutPage.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { __experimental_CheckoutProps, __experimental_CommerceCheckoutResource } from '@clerk/types';
2+
import { useEffect } from 'react';
23

34
import { Alert, Box, localizationKeys, Spinner } from '../../customizables';
45
import { Drawer, useDrawerContext } from '../../elements';
@@ -9,7 +10,7 @@ import { CheckoutForm } from './CheckoutForm';
910

1011
export const CheckoutPage = (props: __experimental_CheckoutProps) => {
1112
const { planId, planPeriod, subscriberType, onSubscriptionComplete } = props;
12-
const { setIsOpen } = useDrawerContext();
13+
const { setIsOpen, isOpen } = useDrawerContext();
1314

1415
const { checkout, isLoading, invalidate, revalidate, updateCheckout, isMissingPayerEmail } = useCheckout({
1516
planId,
@@ -23,6 +24,12 @@ export const CheckoutPage = (props: __experimental_CheckoutProps) => {
2324
onSubscriptionComplete?.();
2425
};
2526

27+
useEffect(() => {
28+
if (isOpen) {
29+
revalidate();
30+
}
31+
}, [isOpen]);
32+
2633
if (isLoading) {
2734
return (
2835
<Spinner

0 commit comments

Comments
 (0)