Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

render only on visible

Kevin Grüneberg861cf7899b6a
diff --git a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx
index ff7700e1f0e..8fdcc6ef764 100644
--- a/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx
+++ b/studio/components/interfaces/Billing/AddNewPaymentMethodModal/AddNewPaymentMethodModal.tsx
@@ -34,7 +34,7 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =
useEffect(() => {
const loadPaymentForm = async () => {
console.log('load payment form', { visible, captchaLoaded, captchaRef })
- if (visible && captchaLoaded && captchaRef) {
+ if (visible && captchaRef && captchaLoaded) {
let token = captchaToken
if (!token) {
const captchaResponse = await captchaRef.execute({ async: true })
@@ -49,7 +49,7 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =
}
loadPaymentForm()
- }, [visible, captchaLoaded, captchaRef])
+ }, [visible, captchaRef, captchaLoaded])
const onCaptchaLoaded = () => {
console.log('on captcha loaded')
@@ -95,19 +95,21 @@ const AddNewPaymentMethodModal: FC<Props> = ({ visible, returnUrl, onCancel }) =
onCancel={onCancel}
className="PAYMENT"
>
- <HCaptcha
- ref={captchaRefCallback}
- sitekey={process.env.NEXT_PUBLIC_HCAPTCHA_SITE_KEY!}
- size="invisible"
- onLoad={onCaptchaLoaded}
- onError={(err) => console.error(err)}
- onVerify={(token) => {
- setCaptchaToken(token)
- }}
- onExpire={() => {
- setCaptchaToken(null)
- }}
- />
+ {visible && (
+ <HCaptcha
+ ref={captchaRefCallback}
+ sitekey={process.env.NEXT_PUBLIC_HCAPTCHA_SITE_KEY!}
+ size="invisible"
+ onError={(err) => console.error(err)}
+ onLoad={() => onCaptchaLoaded()}
+ onVerify={(token) => {
+ setCaptchaToken(token)
+ }}
+ onExpire={() => {
+ setCaptchaToken(null)
+ }}
+ />
+ )}
<div className="space-y-4 py-4">
{intent !== undefined ? (
<Elements stripe={stripePromise} options={options}>