firebase / snippets-web

Web snippets for firebase.google.com
Apache License 2.0
737 stars 241 forks source link

Recaptcha Verifier throws an error #346

Open Mark-WebHabit opened 1 year ago

Mark-WebHabit commented 1 year ago

I'm pretty sure i'm doing it right, but the RecaptchaVerifier is causing this error: TypeError: Cannot read property 'prototype' of undefined, js engine: hermes, it is written in react native: import { StatusBar } from "expo-status-bar"; import { StyleSheet, Text, View, Button } from "react-native"; import { auth } from "./firebaseConfig"; import { useRef } from "react"; import { RecaptchaVerifier, signInWithPhoneNumber } from "firebase/auth";

export default function App() { let phone = "+639612895391"; const myRef = useRef();

const generateRecaptcha = () => { window.recaptchaVerifier = new RecaptchaVerifier( myRef.current, { size: "invisible", callback: (response) => { // reCAPTCHA solved, allow signInWithPhoneNumber. // onSignInSubmit(); }, }, auth ); };

const requestOtp = () => { generateRecaptcha(); let appVerifier = window.recaptchaVerifier; signInWithPhoneNumber(auth, phone, appVerifier) .then((confirmationResult) => { // SMS sent. Prompt user to type the code from the message, then sign the // user in with confirmationResult.confirm(code). window.confirmationResult = confirmationResult; // ... console.log("success"); }) .catch((error) => { // Error; SMS not sent // ... console.log(error); }); }; return (

Open up App.js to start working on your app!