manifold/web/hooks/use-user-bets.ts

13 lines
320 B
TypeScript

import { useEffect, useState } from 'react'
import { Bet, listenForUserBets } from '../lib/firebase/bets'
export const useUserBets = (userId: string) => {
const [bets, setBets] = useState<Bet[] | 'loading'>('loading')
useEffect(() => {
return listenForUserBets(userId, setBets)
}, [userId])
return bets
}