// Example of using the the custom hook to load recaptcha. import useGlobalLib from "./useGlobalLib"; const recaptchaURL = "https://www.google.com/recaptcha/api.js"; function useRecaptcha(action) { const { grecaptcha, loading, error } = useGlobalLib( "grecaptcha", recaptchaURL ); if (error) return { error, loading: false }; if (loading) return { loading: true, error: false }; const getRecaptchaToken = () => { // Use the lib! // grecaptcha.execute... }; return { loading: false, error: false, getRecaptchaToken }; } export default useRecaptcha;