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

reCAPTCHA has already been rendered in this element #262

Open
philonor opened this issue Oct 31, 2019 · 4 comments
Open

reCAPTCHA has already been rendered in this element #262

philonor opened this issue Oct 31, 2019 · 4 comments

Comments

@philonor
Copy link

philonor commented Oct 31, 2019

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

Reproduction

Workarounds

Related

@fresquer
Copy link

@philonor as I found here #229 the issue is really easy to fix.

Use isBrowser of useSSR Hook https://github.com/alex-cory/use-ssr

{isBrowser && <Recaptcha/> }

@rlaphoenix
Copy link

rlaphoenix commented Dec 1, 2019

@fernandopulsa Saved my ass!, But is there a reason we don't just do { typeof window !== 'undefined' && <Recaptcha /> } as window will be undefined when in SSR.

@fresquer
Copy link

fresquer commented Dec 2, 2019

Gatsby JS is not a SSR tool. If you try to use windows on the server will crush. To protect you for any undefined you must to use window with componentDidMount()

More info:
gatsbyjs/gatsby#309

@senorgeno
Copy link

Using a unique elementID worked for me.

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

No branches or pull requests

4 participants