overleaf/services/web/frontend/js/shared/hooks/use-recaptcha.ts
Mathias Jakobsen af76768eb7 Merge pull request #13372 from overleaf/mj-captcha-add-email
[web] Add recaptcha to add-email

GitOrigin-RevId: 0540e0dbc3103dcaac87dd7fabeedbc5892c371c
2023-07-17 10:40:08 +00:00

13 lines
388 B
TypeScript

import { LegacyRef, createRef } from 'react'
import ReCAPTCHA from 'react-google-recaptcha'
export const useRecaptcha = () => {
const ref: LegacyRef<ReCAPTCHA> = createRef<ReCAPTCHA>()
const getReCaptchaToken = async (): Promise<string | null> => {
if (!ref.current) {
return null
}
return await ref.current.executeAsync()
}
return { ref, getReCaptchaToken }
}