@@ -8,7 +8,7 @@ import type {
8
8
ConfirmCheckoutParams ,
9
9
} from '@clerk/types' ;
10
10
import type { SetupIntent } from '@stripe/stripe-js' ;
11
- import { useEffect , useMemo , useState } from 'react' ;
11
+ import { useMemo , useState } from 'react' ;
12
12
13
13
import { useCheckoutContext } from '../../contexts' ;
14
14
import { Box , Button , Col , descriptors , Form , localizationKeys , Text } from '../../customizables' ;
@@ -118,7 +118,6 @@ const CheckoutFormElements = ({
118
118
const { organization } = useOrganization ( ) ;
119
119
const { subscriber, subscriberType } = useCheckoutContext ( ) ;
120
120
121
- const [ paymentMethodSource , setPaymentMethodSource ] = useState < PaymentMethodSource > ( 'existing' ) ;
122
121
const [ isSubmitting , setIsSubmitting ] = useState ( false ) ;
123
122
const [ submitError , setSubmitError ] = useState < ClerkRuntimeError | ClerkAPIError | string | undefined > ( ) ;
124
123
@@ -130,9 +129,9 @@ const CheckoutFormElements = ({
130
129
) ;
131
130
const { data : paymentSources } = data || { data : [ ] } ;
132
131
133
- useEffect ( ( ) => {
134
- setPaymentMethodSource ( paymentSources . length > 0 ? 'existing' : 'new' ) ;
135
- } , [ paymentSources ] ) ;
132
+ const [ paymentMethodSource , setPaymentMethodSource ] = useState < PaymentMethodSource > ( ( ) =>
133
+ paymentSources . length > 0 ? 'existing' : 'new' ,
134
+ ) ;
136
135
137
136
const confirmCheckout = async ( params : ConfirmCheckoutParams ) => {
138
137
try {
0 commit comments