Skip to content

Commit

Permalink
πŸ› init captcha bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
erickcrus committed Jan 4, 2024
1 parent ae1d4b6 commit a33c371
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@erickcrus/react-native-recaptcha",
"version": "0.1.5",
"version": "0.1.6",
"private": false,
"license": "MIT",
"description": "βš› A lightweight new invisible recaptcha lib",
Expand Down
17 changes: 15 additions & 2 deletions src/Recaptcha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,33 @@ const Recaptcha = forwardRef<RecaptchaRef, RecaptchaProps>((props, $ref) => {
}

const handleOpen = () => {
// prevent expiring if the recaptcha is already loaded
$webView.current?.injectJavaScript(`
setTimeout(() => {
grecaptcha.reset();
}, 0);
true;
`);

// if the recaptcha dont respond in 30 seconds, the error callback will be called
timeout.current = setTimeout(() => {
onError && onError('timeout');
containerOpacity.value = 0;
containerZIndex.value = -1000;
$webView.current?.injectJavaScript(`
grecaptcha.reset('submit');
grecaptcha.reset();
true;
`);
setLoading(false);
}, 30000);

// run recaptcha
containerOpacity.value = 1;
containerZIndex.value = 100000;
$webView.current?.injectJavaScript(`
grecaptcha.execute();
setTimeout(() => {
grecaptcha.execute();
}, 100);
true;
`);
setLoading(true);
Expand Down

0 comments on commit a33c371

Please sign in to comment.