File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ export default class ReCAPTCHA extends React.Component {
5050
5151 explicitRender ( cb ) {
5252 if ( this . props . grecaptcha && this . state . widgetId === undefined ) {
53- const id = this . props . grecaptcha . render ( this . captcha , {
53+ const wrapper = document . createElement ( "div" ) ;
54+ const id = this . props . grecaptcha . render ( wrapper , {
5455 sitekey : this . props . sitekey ,
5556 callback : this . props . onChange ,
5657 theme : this . props . theme ,
@@ -61,6 +62,8 @@ export default class ReCAPTCHA extends React.Component {
6162 stoken : this . props . stoken ,
6263 badge : this . props . badge ,
6364 } ) ;
65+ this . captcha . appendChild ( wrapper ) ;
66+
6467 this . setState ( {
6568 widgetId : id ,
6669 } , cb ) ;
@@ -79,6 +82,15 @@ export default class ReCAPTCHA extends React.Component {
7982 this . explicitRender ( ) ;
8083 }
8184
85+ componentWillUnmount ( ) {
86+ if ( this . state . widgetId !== undefined ) {
87+ while ( this . captcha . firstChild ) {
88+ this . captcha . removeChild ( this . captcha . firstChild ) ;
89+ }
90+ this . reset ( ) ;
91+ }
92+ }
93+
8294 handleRecaptchaRef ( elem ) {
8395 this . captcha = elem ;
8496 }
You can’t perform that action at this time.
0 commit comments