@@ -8,7 +8,7 @@ import type {
88 ConfirmCheckoutParams ,
99} from '@clerk/types' ;
1010import type { SetupIntent } from '@stripe/stripe-js' ;
11- import { useEffect , useMemo , useState } from 'react' ;
11+ import { useMemo , useState } from 'react' ;
1212
1313import { useCheckoutContext } from '../../contexts' ;
1414import { Box , Button , Col , descriptors , Form , localizationKeys , Text } from '../../customizables' ;
@@ -118,7 +118,6 @@ const CheckoutFormElements = ({
118118 const { organization } = useOrganization ( ) ;
119119 const { subscriber, subscriberType } = useCheckoutContext ( ) ;
120120
121- const [ paymentMethodSource , setPaymentMethodSource ] = useState < PaymentMethodSource > ( 'existing' ) ;
122121 const [ isSubmitting , setIsSubmitting ] = useState ( false ) ;
123122 const [ submitError , setSubmitError ] = useState < ClerkRuntimeError | ClerkAPIError | string | undefined > ( ) ;
124123
@@ -130,9 +129,9 @@ const CheckoutFormElements = ({
130129 ) ;
131130 const { data : paymentSources } = data || { data : [ ] } ;
132131
133- useEffect ( ( ) => {
134- setPaymentMethodSource ( paymentSources . length > 0 ? 'existing' : 'new' ) ;
135- } , [ paymentSources ] ) ;
132+ const [ paymentMethodSource , setPaymentMethodSource ] = useState < PaymentMethodSource > ( ( ) =>
133+ paymentSources . length > 0 ? 'existing' : 'new' ,
134+ ) ;
136135
137136 const confirmCheckout = async ( params : ConfirmCheckoutParams ) => {
138137 try {
0 commit comments