-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
46 lines (39 loc) · 973 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
firebase.initializeApp({
.....
})
const auth = firebase.auth();
auth.onAuthStateChanged((user) => {
if (user) {
// User is signed in, see docs for a list of available properties
// https://firebase.google.com/docs/reference/js/firebase.User
const uid = user.uid;
console.log("User is signed in");
console.log(user)
} else {
// User is signed out
console.log("User is signed out");
}
})
const goSignAnonymously = async (e) => {
auth.signInAnonymously
.then((result)=>{
let credential = result.credential;
console.log(credential)
}).catch((error)=>{
console.log(error)
});
}
const goSignOut = async (e) => {
auth.signOut();
}
function App() {
return (
<div className="App">
<button onClick={goSignAnonymously}>Sign-In</button>
<button onClick={goSignOut}>Sign-out</button>
</div>
);
}
export default App;