如何在 React Native 应用程序中实现 recaptcha? [英] how to implement recaptcha in react native app?

查看:52
本文介绍了如何在 React Native 应用程序中实现 recaptcha?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了npm install react-native-recaptcha-v3"来集成recaptcha.但是它给出了一个警告失败的道具类型:道具url"在ReCaptcha"中被标记为必需,但它的值为未定义".我做错了什么?

如何解决?

 render() {返回 (<查看><ReCaptcha站点密钥= {this.props.sitekey}verifyCallback={this.verifyCallback.bind(this)}/></查看>);}

解决方案

<ReCaptcha站点密钥={站点密钥}action=""//这不是必需的,但如果您多次使用 recaptcha,则可以这样做.url="<use_any_valid_url_or_app_related_url>"reCaptchaType={1}onExecute={(res) =>{this.setState({ reCaptcha: res });}}/>

<块引用>

react-native-recaptcha-v3 需要 URL 道具,因此您可以传递任何有效的 URL 或与应用程序相关的 URL,并确保 URL 以https://stackoverflow.com/'.如果您只是使用stackoverflow.com"作为 URL,则会显示 URL 错误.一旦从 render onExecute() 执行并在 res 变量中,您就会获得 recaptcha 令牌,您可以使用它来验证 recaptcha.还有一点,在 react-native-recaptcha-v3 中没有像 verifyCallback 这样的道具.所以不要使用它.

I have used "npm install react-native-recaptcha-v3" for recaptcha integration. But it gives a warning Failed prop type: The prop 'url' is marked as required in 'ReCaptcha', but its value is 'undefined'. what was I do wrong?

how to resolve it?

     render() {
        return (
        <View>
        <ReCaptcha
          sitekey= {this.props.sitekey}
          verifyCallback={this.verifyCallback.bind(this)}
        />
       </View>
       );
      }

解决方案

<ReCaptcha
   siteKey={SiteKey}
   action="<action_name>" // it's not required but you can it if you are using recaptcha more than one time.
   url="<use_any_valid_url_or_app_related_url>"
   reCaptchaType={1}
   onExecute={(res) => {
      this.setState({ reCaptcha: res });
   }}
/>

URL props is required for react-native-recaptcha-v3 so you can pass any valid URL or app related URL and make sure URL starts with something like 'https://stackoverflow.com/'. if you simply use 'stackoverflow.com' as URL it shows an error for URL. As soon as from render onExecute() executes and in res variable, you got the recaptcha token, which you can use for verifying the recaptcha. and one more point, there are no props like verifyCallback in react-native-recaptcha-v3. So don't use it.

这篇关于如何在 React Native 应用程序中实现 recaptcha?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆