react-google-recaptcha 版本:2.0.0-rc.1
我在重置 recaptcha 时遇到问题
我正在使用功能组件
代码摘录如下
// imports etc.. here
const Login: NextPage = (props:any) => {
// othere initializations here...
const recaptchaInputRef:any = React.createRef();
const handleSubmit = async (event) => {
// some if condition
// and else
// and inside there
recaptchaInputRef.current.reset();
}
return (
<React.Fragment>
<form onSubmit={e => handleSubmit(e)}>
// other components and elements
<ReCAPTCHA
ref={recaptchaInputRef}
sitekey={props.recaptchaKey}
onChange={ onChange }
onExpired={ onExpired }
/>
<Button type="submit">Sign In</Button>
</form>
</React.Fragment>
);
现在的问题是,我得到 - 无法读取代码的 null 属性“重置”->recaptchaInputRef.current.reset();