Skip to content

Commit ca804cb

Browse files
committed
Remove timeout removal, remove component unmount
1 parent afd6eb3 commit ca804cb

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

src/recaptcha.js

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ export default class ReCAPTCHA extends React.Component {
4848
}
4949
}
5050

51+
forceReset() {
52+
if (this.props.grecaptcha) {
53+
this.props.grecaptcha.reset();
54+
}
55+
}
56+
5157
handleExpired() {
5258
if (this.props.onExpired) {
5359
this.props.onExpired();
@@ -111,29 +117,6 @@ export default class ReCAPTCHA extends React.Component {
111117
this.explicitRender();
112118
}
113119

114-
componentWillUnmount() {
115-
if (this._widgetId !== undefined) {
116-
this.delayOfCaptchaIframeRemoving();
117-
this.reset();
118-
}
119-
}
120-
121-
delayOfCaptchaIframeRemoving() {
122-
const temporaryNode = document.createElement("div");
123-
document.body.appendChild(temporaryNode);
124-
temporaryNode.style.display = "none";
125-
126-
// move of the recaptcha to a temporary node
127-
while (this.captcha.firstChild) {
128-
temporaryNode.appendChild(this.captcha.firstChild);
129-
}
130-
131-
// delete the temporary node after reset will be done
132-
setTimeout(() => {
133-
document.body.removeChild(temporaryNode);
134-
}, 5000);
135-
}
136-
137120
handleRecaptchaRef(elem) {
138121
this.captcha = elem;
139122
}

0 commit comments

Comments
 (0)