Skip to content

Instantly share code, notes, and snippets.

@polluterofminds
Last active September 22, 2021 14:59
Show Gist options
  • Save polluterofminds/00f75f64476645bbda067e65f6584802 to your computer and use it in GitHub Desktop.
Save polluterofminds/00f75f64476645bbda067e65f6584802 to your computer and use it in GitHub Desktop.
Top Shot user-hook
import * as fcl from "@onflow/fcl"
import { useState, useEffect } from 'react';
export function useCurrentUser() {
const [user, setUser] = useState(null);
useEffect(() => {
fcl.currentUser().subscribe(setUser)
}, []);
return {
currentUser: user,
logOut: fcl.unauthenticate,
logIn: fcl.logIn,
signUp: fcl.signUp,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment