matei-radu / react-recaptcha-v2

Google reCAPTCHA v2 React component that does not pollute the DOM.
MIT License
7 stars 1 forks source link

ReCAPTCHA couldn't find user-provided function #26

Closed alechko closed 1 year ago

alechko commented 1 year ago

When using ReCAPTCHA in Docusaurus build the callbacks are throwing an error:

ReCAPTCHA couldn't find user-provided function: Nd-Js-alO_sDUNCE_sZ10 recaptcha__en.js:231:455

In development version there's no issue and it works fine, but running from build the callback is not working, any idea what's the issue?

"react": "^17.0.2", "react-dom": "^17.0.2", "@matt-block/react-recaptcha-v2": "^2.0.0"

alechko commented 1 year ago

closing my issue as the solution is actually in Docusaurus SSR, wrapping the form with <BrowserOnly> fixed this issue.

matei-radu commented 1 year ago

Yeah, I think that is necessary. ReCAPTCHA requires some interactions with the Window object and generally the DOM (that is, outside of React's VDOM state), so it cannot be correctly rendered server-side.