// Login.tsx import React, { useEffect, useState } from 'react'; import { Button, Keyboard, Text, TextInput, TouchableWithoutFeedback, View, } from 'react-native'; import { handleSignInWithPhoneNumber, confirmCode, onAuthStateChanged } from '../auth'; import { FirebaseAuthTypes } from '@react-native-firebase/auth'; import { useAuthHeader } from '../graphql/client'; import AsyncStorage from '@react-native-async-storage/async-storage'; import SignOutButton from '../component/buttons/sign-out'; export default function Login() { const [phoneNumber, setPhoneNumber] = useState(''); const [code, setCode] = useState(''); const [user, setUser] = useState(null); const [confirm, setConfirm] = useState(null); const { authHeader, setAuthHeader } = useAuthHeader() useEffect(() => { const unsubscribe = onAuthStateChanged(async (user) => { setUser(user) if (user) { const token = await user.getIdToken() if (token) { await AsyncStorage.setItem('token', token); setAuthHeader({ key: "Authorization", value: `Bearer ${token}` }); } } }); return unsubscribe; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( Keyboard.dismiss()}> setPhoneNumber(value)} /> {confirm && ( setCode(value)} /> )}