dozoisch / dozoisch/react-google-recaptcha

calling ref.current.execute() in functional component fails to produce any results.

Open
#201 20 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.1k
Forks
148
PR merge metrics
No merged PRs in 30d

Description

react-google-recaptcha version: 2.1.0
react-async-script version: 1.2.0

I have the most simple setup and I cannot seem to get it to work:

```
import React, { useRef, useState } from "react";
import { ReCAPTCHA } from "react-google-recaptcha";

export default function App() {
const captchaRef = useRef();
const [text, setText] = useState("Start editing to see some magic happen!");
return (


Hello CodeSandbox


{text}


{
setText("yes. it was a click");
captchaRef.current.execute();
}}
>
Click me

{
setText(`There you go ${value}`);
}}
size="invisible"
/>

);
}
```

or check out the [codesandbox](https://codesandbox.io/s/elated-benz-f2ovz?file=/src/App.js)

The problem is, that the current.execute never does anything. Clicking the button never fires any request. At the same time, a similar example seems to work just fine: https://codesandbox.io/s/gifted-cache-10q74jj593?file=/src/index.js

So what am I missing here? Is'nt my example even more dumbed down and simpler.. have I forgot something?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.