Skip to content

Commit 34bf764

Browse files
committed
Fix race on execute()
Previously, if the call to execute() happened before the script is asynchnonously loaded and fully rendered, the Captcha would never execute.
1 parent 7219e56 commit 34bf764

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/recaptcha.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export default class ReCAPTCHA extends React.Component {
2222

2323
if (grecaptcha && widgetId !== undefined) {
2424
return grecaptcha.execute(widgetId);
25+
} else {
26+
this._executeRequested = true;
2527
}
2628
}
2729

@@ -56,6 +58,10 @@ export default class ReCAPTCHA extends React.Component {
5658
widgetId: id,
5759
}, cb);
5860
}
61+
if (this._executeRequested && this.props.grecaptcha && this.state.widgetId !== undefined) {
62+
this._executeRequested = false;
63+
this.execute();
64+
}
5965
}
6066

6167
componentDidMount() {

0 commit comments

Comments
 (0)