Answer the question
In order to leave comments, you need to log in
How to reload invisible recaptcha in react spa?
Hello everyone, I have a react app using react-router. I'm trying to implement recaptcha on the login page, but I'm facing a problem that the widget doesn't wake up if after login I go through the pages, log out and return to the login page. The captcha is attached to the button.
<Button
className="g-recaptcha"
data-sitekey="********************"
data-callback="invisibleLogin"
/>
Answer the question
In order to leave comments, you need to log in
I ended up doing this and it seems to work :)
componentDidMount(){
window.invisibleLogin = this.invisibleLogin;
this.loadJS("https://www.google.com/recaptcha/api.js")
}
loadJS(url){
const script = document.createElement('script');
script.src = url;
script.type = 'text/javascript';
script.async = true;
script.defer = true;
script.onerror = function( error ) { throw error; };
document.body.appendChild( script );
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question