23 lines
641 B
TypeScript
23 lines
641 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import { listenForFollowers, listenForFollows } from 'web/lib/firebase/users'
|
|
|
|
export const useFollows = (userId: string | null | undefined) => {
|
|
const [followIds, setFollowIds] = useState<string[] | undefined>()
|
|
|
|
useEffect(() => {
|
|
if (userId) return listenForFollows(userId, setFollowIds)
|
|
}, [userId])
|
|
|
|
return followIds
|
|
}
|
|
|
|
export const useFollowers = (userId: string | undefined) => {
|
|
const [followerIds, setFollowerIds] = useState<string[] | undefined>()
|
|
|
|
useEffect(() => {
|
|
if (userId) return listenForFollowers(userId, setFollowerIds)
|
|
}, [userId])
|
|
|
|
return followerIds
|
|
}
|