无法设置反应验证码

问题描述

我正在以我的形式设置react recaptcha。我已经阅读了文档,但是找不到我的错误。我要实现的目标是,一旦用户成功完成了recapcha,那么只有他/她的数据将通过发布请求发送到仪表板。

import React,{ Fragment,useState } from "react";
import axios from "axios";

let Recaptcha = require("react-recaptcha");

const Form = () => {
  const [candidate,setCandidate] = useState({
    //candidate fields
  });

  let isverified = false;

  let callback = function () {
    console.log("Done!!!!");
  };

  let verifyCallback = function (response) {
    console.log(response);
    if(response){
      isverified = true;
  }
};

  const onChange = e =>
    setCandidate({ ...candidate,[e.target.name]: e.target.value });

  const onSubmit = e => {
    e.preventDefault();

    if (isverified === true) {
            //axios post request
        });

      isverified = false; //re setting it to false 
    }
  };

return (
    <Fragment>
      <form onSubmit={onSubmit}>
        <div className="form-group">
          <div className="form-row">
               //form input 

          <Recaptcha
            sitekey="xxxxxxxxxxx"
            render="explicit"
            verifyCallback={verifyCallback}
            onloadCallback={callback}
          />
        </div>
      </form>
    </Fragment>
  );
};

export default Form;

每当我尝试加载表单时,控制台中都会出现错误reCAPTCHA Couldn't find user-provided function: onloadCallback

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)