2021-12-12 22:14:52 +00:00
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
import { Bet, listenForBets } from '../lib/firebase/bets'
|
|
|
|
|
|
|
|
export const useBets = (contractId: string) => {
|
2022-01-15 00:16:25 +00:00
|
|
|
const [bets, setBets] = useState<Bet[] | undefined>()
|
2021-12-12 22:14:52 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (contractId) return listenForBets(contractId, setBets)
|
|
|
|
}, [contractId])
|
|
|
|
|
|
|
|
return bets
|
|
|
|
}
|