appleboy / appleboy/react-recaptcha

reCAPTCHA has already been rendered in this element

Open
#262 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
643
Forks
96
PR merge metrics
No merged PRs in 30d

Description

**Description**
When using react-recaptcha in a GatsbyJS project and switching between pages containing the same component with a reCAPTCHA, rendering fails. It also fails when opening a direct link to one of the two pages.

![gatsby-recaptcha-reproduction](https://user-images.githubusercontent.com/5816039/67935092-787d8100-fbc9-11e9-9698-e470de845bec.gif)

**Reproduction**
- See repo https://github.com/philonor/gatsby-recaptcha-reproduction that is a gatsby-starter-default clone with two more pages [`contact-en.js`](https://github.com/philonor/gatsby-recaptcha-reproduction/blob/repro/src/pages/contact-de.js) and [`contact-de.js`](https://github.com/philonor/gatsby-recaptcha-reproduction/blob/repro/src/pages/contact-de.js) that both contain the same [`ContactForm`](https://github.com/philonor/gatsby-recaptcha-reproduction/blob/repro/src/components/contact-form.js) component which uses react-recaptcha to render a recaptcha.
- Clone it, run `npm i`, then `gatsby build && gatsby serve`, then browse to `http://localhost:9000/contact-de/` to reproduce the error (you may have to hit the refresh button a few times until the error occurrs).

**Workarounds**
- Requiring explicit rendering and specifying an `onloadCallback` seem to fix the issue https://github.com/appleboy/react-recaptcha/issues/181#issuecomment-280800414

**Related**
- https://github.com/appleboy/react-recaptcha/issues/229
- https://github.com/appleboy/react-recaptcha/issues/181
- https://github.com/escaladesports/gatsby-plugin-recaptcha/issues/1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.