How to use the reactfire.useUser function in reactfire

To help you get started, we’ve selected a few reactfire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prescottprue / generator-react-firebase / examples / react-firebase / src / routes / Account / components / AccountEditor / AccountEditor.js View on Github external
function AccountEditor() {
  const classes = useStyles()
  const firebase = useFirebaseApp()
  const auth = useUser()
  const accountRef = firebase.database().ref(`users/${auth.uid}`)
  const profileSnap = useDatabaseObject(accountRef)
  const profile = profileSnap.snapshot.val()

  function updateAccount(newAccount) {
    return firebase
      .updateProfile(newAccount)
      .then(() => accountRef.update(newAccount))
      .catch(error => {
        console.error('Error updating profile', error.message || error) // eslint-disable-line no-console
        return Promise.reject(error)
      })
  }

  return (
github prescottprue / generator-react-firebase / examples / react-firebase / src / routes / Projects / components / ProjectsList / ProjectsList.js View on Github external
function useProjectsList() {
  // Get current user (loading handled by Suspense in ProjectsList)
  const auth = useUser()
  const firebase = useFirebaseApp()

  // Create a ref for projects owned by the current user
  const projectsRef = firebase
    .database()
    .ref('projects')
    .orderByChild('createdBy')
    .equalTo(auth.uid)

  // Query for projects (loading handled by Suspense in ProjectsList)
  const projects = useDatabaseList(projectsRef)

  // New dialog
  const [newDialogOpen, changeDialogState] = useState(false)
  const toggleDialog = () => changeDialogState(!newDialogOpen)
github FirebaseExtended / reactfire / sample / src / Auth.js View on Github external
const FirebaseAuthStateButton = () => {
  const user = useUser();
  return user ?  : ;
};
github prescottprue / generator-react-firebase / examples / react-firebase / src / containers / Navbar / Navbar.js View on Github external
function Navbar() {
  const classes = useStyles()
  const auth = useUser()
  const authExists = !!auth && !!auth.uid

  return (
    
      {authExists ? (
        
      ) : (
        <button data-test="sign-in">
          Sign In
        </button>
      )}