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

13 lines
320 B
TypeScript
Raw Normal View History

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
}