Skip to content

Commit

Permalink
Fix race on execute()
Browse files Browse the repository at this point in the history
Previously, if the call to execute() happened before
the script is asynchnonously loaded and fully rendered,
the Captcha would never execute.
  • Loading branch information
aij committed Jun 19, 2017
1 parent 7219e56 commit 34bf764
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/recaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default class ReCAPTCHA extends React.Component {

if (grecaptcha && widgetId !== undefined) {
return grecaptcha.execute(widgetId);
} else {
this._executeRequested = true;
}
}

Expand Down Expand Up @@ -56,6 +58,10 @@ export default class ReCAPTCHA extends React.Component {
widgetId: id,
}, cb);
}
if (this._executeRequested && this.props.grecaptcha && this.state.widgetId !== undefined) {
this._executeRequested = false;
this.execute();
}
}

componentDidMount() {
Expand Down

0 comments on commit 34bf764

Please sign in to comment.