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 from 'react'; | |
| import { auth } from './firebase'; | |
| function Login() { | |
| const login = async () => { | |
| const provider = new auth.GoogleAuthProvider(); | |
| try { | |
| await auth().signInWithPopup(provider); | |
| } catch (e) {} | |
| }; |
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
| try { | |
| await auth().signInWithPopup(provider); | |
| const user = await auth().currentUser; | |
| setUser(user); | |
| } catch(e) {} |
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
| React.useEffect(() => { | |
| return auth().onAuthStateChanged((user) => { | |
| if (user) { | |
| setUser(user); | |
| } else { | |
| setUser(null); | |
| } | |
| }); | |
| }, []); |
OlderNewer