douglasjunior / react-native-recaptcha-that-works

⚛ A reCAPTCHA bridge for React Native that works (Android and iOS)
MIT License
167 stars 33 forks source link

expo sdk42 - onError: ["Error null"] #18

Closed celsodevelop closed 3 years ago

celsodevelop commented 3 years ago

Hi! First of all! Thank you to share this awesome lib. I was trying to use this at Expo SDK 42 "managed workflow" react-native project linking to firebase. Below are my packages related:

"expo": "^42.0.0", "expo-firebase-recaptcha": "^1.4.2", "firebase": "8.2.3", "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz", "react-native-recaptcha-that-works": "^1.1.0", "react-native-webview": "11.6.2"

Issue: Since I start reCaptcha flow it invokes onError and console warns "Error: null".

Workaround(?): I use your code as a template to locate where would the issue come from. As a junior, in advance, I want to apologize any misunderstood concept by myself. I tried use your concepts of nesting webview starting from render hello world and adding handlers like yours handleMessage and stuck at this problem at function getTemplate when it acts over "template" string variable. The workaround was just to assign de return from replace() to a new that function scoped variable and return. I will appreciate this issue can help others to use this awesome library and skilled ones help us fixing this behaviour, if it was a issue to anyone.

    const getTemplate = useCallback((params) => {
    let output;
    Object.entries(params).forEach(([key, value]) => {
// template = template.replace( ...
      output = template.replace(new RegExp(`{{${key}}}`, 'img'), value); //line change
    });
    return output;
  }, []);

Sorry about my english too. Thank you owner and contributors.

douglasjunior commented 3 years ago

Sorry, but I dont have experience with expo.

I think that the problem is not related to getTemplate function, because we are using this lib on many bare react-native projects, with no problem.

Btw, your sample code will not work, because the getTemplate function need to replace ALL the props received on params object.

celsodevelop commented 3 years ago

Sorry douglasjunior, if it is not an issue. I think it should have a minimal reproducible error code to help us. Maybe some Expo issue? I will try to post the snack Expo along with the error happening as soon as I can. thank you

Sorry, but I dont have experience with expo.

I think that the problem is not related to getTemplate function, because we are using this lib on many bare react-native projects, with no problem.

Btw, you sample code will not work, because the getTemplate function need to replace ALL the props received on params object.

douglasjunior commented 3 years ago

We have a snack https://snack.expo.dev/@douglasjunior/react-native-recaptcha-that-works

celsodevelop commented 3 years ago

Hi douglas, since I can't reproduce this in a minimal approach at snack changing expo to sdk42, I will be closing this issue until I am sure about where it came from. Thank you so much for this great lib!

ashuOxit commented 2 years ago

Hi @celsodevelop i did face the same issue when I tried to load recaptcha it showing me error with null this happened when I am using "react-native-webview": "^11.23.1", "react-native": "0.63.4", Can you help me

douglasjunior commented 2 years ago

Probably you don't have configured properly the siteKey or baseUrl.

Our snack is working without errors https://snack.expo.dev/@douglasjunior/react-native-recaptcha-that-works

nikiforos-dev commented 5 months ago

the problem is that it works on expo when you run in the development mode npx expo start (which is what is happening in the snack), but not when you build a development build npx expo start --dev-client. I really wish this would somehow work in expo, since I can't find any alternative to complete captcha in Expo

douglasjunior commented 5 months ago

I don't think we have a problem related to release or debug builds, because this library is pure JavaScript, which doesn't have any difference between the two types of builds.

The only dependency that has native code is react-native-webview, which comes by default with expo.