manifold/web/hooks/use-bets.ts

13 lines
327 B
TypeScript

import { useEffect, useState } from 'react'
import { Bet, listenForBets } from '../lib/firebase/bets'
export const useBets = (contractId: string) => {
const [bets, setBets] = useState<Bet[] | undefined>()
useEffect(() => {
if (contractId) return listenForBets(contractId, setBets)
}, [contractId])
return bets
}