Last active
March 3, 2021 17:01
-
-
Save polluterofminds/9359e1bf7ef4b667413915e26f224c34 to your computer and use it in GitHub Desktop.
1 - Flow React
This file contains 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 * as fcl from "@onflow/fcl" | |
const AuthCluster = () => { | |
const [user, setUser] = useState({loggedIn: null}) | |
useEffect(() => fcl.currentUser().subscribe(setUser), []) | |
if (user.loggedIn) { | |
return ( | |
<div> | |
<span>{user?.addr ?? "No Address"}</span> | |
<button className="btn-primary" onClick={fcl.unauthenticate}>Log Out</button> | |
</div> | |
) | |
} else { | |
return ( | |
<div> | |
<button className="btn-primary" onClick={fcl.logIn}>Log In</button> | |
<button className="btn-secondary" onClick={fcl.signUp}>Sign Up</button> | |
</div> | |
) | |
} | |
} | |
export default AuthCluster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment