Created
April 26, 2020 17:56
-
-
Save suhas86/272872d831a25457562a69ab74de186b 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 React,{useState, useEffect} from 'react'; | |
import './App.scss'; | |
import Signin from './sign-in/Signin'; | |
import Signup from './sign-up/Signup'; | |
import Userinfo from './user-info/Userinfo'; | |
import {auth, createUserProfileDocument} from "./firebase" | |
function App() { | |
const [currentUser,setCurrentUser] = useState(); | |
useEffect(() => { | |
auth.onAuthStateChanged( async userAuth => { | |
if(userAuth) { | |
const user = await createUserProfileDocument(userAuth); | |
user?.onSnapshot((snapshot) => { | |
setCurrentUser({ | |
id: snapshot.id, | |
...snapshot.data(), | |
}); | |
}); | |
} | |
setCurrentUser(userAuth); | |
}) | |
},[]) | |
return ( | |
<div className="App"> | |
<div className="container"> | |
<Signin /> | |
<Signup /> | |
</div> | |
<hr></hr> | |
<Userinfo currentUser={currentUser} /> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment