manifold/web/hooks/use-contracts.ts

26 lines
579 B
TypeScript
Raw Normal View History

2022-01-05 06:32:52 +00:00
import _ from 'lodash'
import { useEffect, useState } from 'react'
2022-01-05 06:32:52 +00:00
import {
Contract,
listenForContracts,
listenForHotContracts,
2022-01-05 06:32:52 +00:00
} from '../lib/firebase/contracts'
export const useContracts = () => {
const [contracts, setContracts] = useState<Contract[] | undefined>()
useEffect(() => {
return listenForContracts(setContracts)
}, [])
return contracts
}
2022-01-05 06:32:52 +00:00
export const useHotContracts = () => {
const [hotContracts, setHotContracts] = useState<Contract[] | undefined>()
2022-01-05 06:32:52 +00:00
useEffect(() => listenForHotContracts(setHotContracts), [])
2022-01-05 06:32:52 +00:00
return hotContracts
2022-01-05 06:32:52 +00:00
}