mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 08:51:55 -05:00
14 lines
388 B
TypeScript
14 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 }
|
||
|
}
|