react-google-recaptcha icon indicating copy to clipboard operation
react-google-recaptcha copied to clipboard

What is the right way to use react-google-recaptcha with react-router?

Open SleepingWhale opened this issue 5 years ago • 3 comments

My application has several routes and only some of them need to use recaptcha. I added component like this for each view component:

<Recaptcha
  ref={this.recaptchaRef}
  sitekey={RECAPTCHA_SITE_KEY}
  size="invisible"
  onChange={this.onSubmit}
  onErrored={this.logCaptchaError}
  theme="dark"
/>

It seems to work but obviously something is wrong with this approach:

  1. Badge disappears after route changing image
  2. all recaptcha scripts get reloaded after route changing
  3. After each initialization recaptcha elements persist in DOM image

Any suggestions will be highly appreciated.

react-google-recaptcha version: 1.0.5

SleepingWhale avatar Apr 09 '19 09:04 SleepingWhale

Same issue. Is there any solution for a hidden badge after a route change?

ermrg avatar Aug 28 '19 07:08 ermrg

@mrg-hub I switched to this one https://github.com/sarneeh/reaptcha

SleepingWhale avatar Aug 29 '19 13:08 SleepingWhale

@SleepingWhale have you been using Strict mode in your app? If so, that is more of a development environment app issue rather than a production (and deployed) one: https://stackoverflow.com/questions/70890193/why-does-recaptcha-disappear-when-i-navigate-to-another-page. So, if you run locally without strict mode, or create a production version of your app, the issue you described should not reproduce.

lapotkov avatar Feb 06 '23 11:02 lapotkov