Skip to content

Commit 50dcd43

Browse files
authored
Merge pull request dozoisch#120 from RubtsovAV/master
Fix promise timeout
2 parents 529efc1 + 9aa2218 commit 50dcd43

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/recaptcha.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,27 @@ export default class ReCAPTCHA extends React.Component {
8484

8585
componentWillUnmount() {
8686
if (this._widgetId !== undefined) {
87-
while (this.captcha.firstChild) {
88-
this.captcha.removeChild(this.captcha.firstChild);
89-
}
87+
this.delayOfCaptchaIframeRemoving();
9088
this.reset();
9189
}
9290
}
9391

92+
delayOfCaptchaIframeRemoving() {
93+
const temporaryNode = document.createElement("div");
94+
document.body.appendChild(temporaryNode);
95+
temporaryNode.style.display = "none";
96+
97+
// move of the recaptcha to a temporary node
98+
while (this.captcha.firstChild) {
99+
temporaryNode.appendChild(this.captcha.firstChild);
100+
}
101+
102+
// delete the temporary node after reset will be done
103+
setTimeout(() => {
104+
document.body.removeChild(temporaryNode);
105+
}, 5000);
106+
}
107+
94108
handleRecaptchaRef(elem) {
95109
this.captcha = elem;
96110
}

0 commit comments

Comments
 (0)