Skip to content

Commit b1a5d87

Browse files
authored
Merge pull request dozoisch#154 from mintyfloss/handlechange
Add handleChange method
2 parents 54af0a2 + e4973c5 commit b1a5d87

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/recaptcha.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class ReCAPTCHA extends React.Component {
66
super();
77
this.handleExpired = this.handleExpired.bind(this);
88
this.handleErrored = this.handleErrored.bind(this);
9+
this.handleChange = this.handleChange.bind(this);
910
this.handleRecaptchaRef = this.handleRecaptchaRef.bind(this);
1011
}
1112

@@ -42,21 +43,25 @@ export default class ReCAPTCHA extends React.Component {
4243
handleExpired() {
4344
if (this.props.onExpired) {
4445
this.props.onExpired();
45-
} else if (this.props.onChange) {
46-
this.props.onChange(null);
46+
} else {
47+
this.handleChange(null);
4748
}
4849
}
4950

5051
handleErrored() {
5152
if (this.props.onErrored) this.props.onErrored();
5253
}
5354

55+
handleChange(token) {
56+
if (this.props.onChange) this.props.onChange(token);
57+
}
58+
5459
explicitRender() {
5560
if (this.props.grecaptcha && this.props.grecaptcha.render && this._widgetId === undefined) {
5661
const wrapper = document.createElement("div");
5762
this._widgetId = this.props.grecaptcha.render(wrapper, {
5863
sitekey: this.props.sitekey,
59-
callback: this.props.onChange,
64+
callback: this.handleChange,
6065
theme: this.props.theme,
6166
type: this.props.type,
6267
tabindex: this.props.tabindex,

0 commit comments

Comments
 (0)