manifold/web/hooks/use-users.ts

24 lines
521 B
TypeScript
Raw Normal View History

import { useState, useEffect } from 'react'
2022-01-24 06:48:06 +00:00
import { PrivateUser, User } from '../../common/user'
import { listenForAllUsers, listenForPrivateUsers } from '../lib/firebase/users'
export const useUsers = () => {
const [users, setUsers] = useState<User[]>([])
useEffect(() => {
listenForAllUsers(setUsers)
}, [])
return users
}
2022-01-24 06:48:06 +00:00
export const usePrivateUsers = () => {
const [users, setUsers] = useState<PrivateUser[]>([])
useEffect(() => {
listenForPrivateUsers(setUsers)
}, [])
return users
}