You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you prefer a React Hook approach over the old good Higher Order Component, you can choose to use the custom hook `useGoogleReCaptcha` over the HOC `withGoogleReCaptcha`.
115
115
116
-
It's very simple to use the hook:
116
+
The `executeRecaptcha` function returned from the hook can be undefined when the recaptcha script has not been successfully loaded.
117
+
You can do a null check to see if it's available or not.
118
+
119
+
How to use the hook:
117
120
118
121
```javascript
119
122
import {
120
123
GoogleReCaptchaProvider,
121
124
useGoogleReCaptcha
122
125
} from'react-google-recaptcha-v3';
123
126
124
-
constYourReCaptchaComponent= () => {
127
+
constYourReCaptchaComponent= () => {
125
128
const { executeRecaptcha } =useGoogleReCaptcha();
126
-
consttoken=executeRecaptcha("login_page");
127
129
128
-
return (...)
129
-
}
130
+
// Create an event handler so you can call the verification on button click event or form submit
0 commit comments