manifold/web/hooks/use-follows.ts
James Grugett 879ab272e0
Following and follower list (#456)
* Create following button that opens follow list in modal.

* Move react query deps to web package.json

* UseFollowers hook

* Following and followers button, dialog with tabs.

* Fix line endings

* Remove carriage return from default vscode eol

* Add placeholder message if no users followed / no followers

* Tweak spacing
2022-06-07 22:24:18 -05:00

23 lines
634 B
TypeScript

import { useEffect, useState } from 'react'
import { listenForFollowers, listenForFollows } from 'web/lib/firebase/users'
export const useFollows = (userId: string | 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
}