Last active
July 2, 2020 19:28
-
-
Save mrcflorian/b93251517dd6239848f8a66ec6160a39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import { firebase } from './src/firebase/config' | |
... | |
export default function App() { | |
... | |
if (loading) { | |
return ( | |
<></> | |
) | |
} | |
useEffect(() => { | |
const usersRef = firebase.firestore().collection('users'); | |
firebase.auth().onAuthStateChanged(user => { | |
if (user) { | |
usersRef | |
.doc(user.uid) | |
.get() | |
.then((document) => { | |
const userData = document.data() | |
setLoading(false) | |
setUser(userData) | |
}) | |
.catch((error) => { | |
setLoading(false) | |
}); | |
} else { | |
setLoading(false) | |
} | |
}); | |
}, []); | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment