manifold/web/hooks/use-bets.ts

13 lines
336 B
TypeScript
Raw Permalink Normal View History

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) => {
const [bets, setBets] = useState<Bet[] | 'loading'>('loading')
useEffect(() => {
if (contractId) return listenForBets(contractId, setBets)
}, [contractId])
return bets
}