Skip to content

Commit

Permalink
Use portal to render recaptch
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Aug 28, 2023
1 parent 198fdd0 commit 555699e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/components/captcha/CaptchaInvisible.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getCaptchaSiteKey } from '@/utils/env/client'
import React, { useRef } from 'react'
import { createPortal } from 'react-dom'
import ReCAPTCHA from 'react-google-recaptcha'
import { toast } from 'react-hot-toast'
import Toast from '../Toast'
Expand Down Expand Up @@ -38,13 +39,16 @@ export default function CaptchaInvisible({ children }: CaptchaInvisibleProps) {
{children(runCaptcha, (className) => (
<CaptchaTermsAndService className={className} />
))}
<ReCAPTCHA
sitekey={getCaptchaSiteKey()}
theme='dark'
ref={captchaRef}
size='invisible'
badge='inline'
/>
{createPortal(
<ReCAPTCHA
sitekey={getCaptchaSiteKey()}
theme='dark'
ref={captchaRef}
size='invisible'
badge='inline'
/>,
document.body
)}
</>
)
}

0 comments on commit 555699e

Please sign in to comment.