const [user, signOut] = useMaybeDoormanUser()
If you want to access the user on a screen where a user may or may not be signed in, then use useMaybeDoormanUser
instead:
import React from 'react'import { Text } from 'react-native'import { useMaybeDoormanUser } from 'react-native-doorman'const MaybeUserDetails = () => {// 👇 notice that the ARRAY syntax (not {} this time!)const [user, signOut] = useMaybeDoormanUser()// check if the user is defined or not firstif (!user) {// if it isn't, then no one is signed in yet!return <Text>Not signed in yet!</Text>}// Ok, now we now there is a user! 🔥const uid = user.uidconst phoneNumber = user.phoneNumberreturn <Text>uid: {uid}, phone: {phoneNumber}</Text>}export default MaybeUserDetails
You'll notice that you do [user, signOut]
using an array instead of squiggly braces. This is done on purpose to make sure this hook is not confused with useDoormanUser
.