Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When use useRecaptchaProvider it throw warning #1429

Open
websitevirtuoso opened this issue Oct 31, 2023 · 4 comments
Open

When use useRecaptchaProvider it throw warning #1429

websitevirtuoso opened this issue Oct 31, 2023 · 4 comments
Labels

Comments

@websitevirtuoso
Copy link

websitevirtuoso commented Oct 31, 2023

Description

I am using vue composition API in setup.

I am using next code

import { useRecaptchaProvider, useChallengeV3 } from 'vue-recaptcha'

useRecaptchaProvider()

... rest of code

But when I open different pages with recaptcha. the same page multiple time it throw warning
useRecaptchaProvider is used multiple time

Minimal Reproducible Example

To make it work I just had to check code and add condition to include provider only once

like this

import { useRecaptchaProvider, useChallengeV3, useRecaptchaContext } from 'vue-recaptcha'
if (!ctx.scriptInjected) {
  useRecaptchaProvider()
}

image

Maybe we have to remove line 8 on screenhot. BUt this question to owner of this lib

System info


  • Operating System: Linux
  • Node Version: v20.2.0
  • Nuxt Version: -
  • CLI Version: 3.9.1
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

@ikuosaito1989
Copy link

Hi @websitevirtuoso

This one is not a bug: useRecaptchaProvider only needs to be called once. The following example defines useRecaptchaProvider in the entry point app.vue

https://dansnow.github.io/vue-recaptcha/guide#provide-recaptcha-script

@awdr74100
Copy link

Hi, is there any way to load useRecaptchaProvider only when navigating to a certain page and avoid multiple loads (lighthouse effect issue)

@Shadercloud
Copy link

How do unmount useRecaptchaProvider(). If you want recaptcha only on certain pages. It seems once you use useRecaptchaProvider() within a component it is then mount across the whole app, and cannot be removed.

@ikuosaito1989
Copy link

Hi, is there any way to load useRecaptchaProvider only when navigating to a certain page and avoid multiple loads (lighthouse effect issue)

@awdr74100
How about trying the following code?

import { useRecaptchaProvider, useRecaptchaContext } from 'vue-recaptcha'
const ctx = useRecaptchaContext()
if (!ctx.scriptInjected) {
  useRecaptchaProvider()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants