acc9c84e2e
* Configure functions module to allow absolute imports * Convert common imports in functions to be absolute * Convert common imports in web to be absolute * Convert lib imports in web to be absolute * Convert hooks imports in web to be absolute * Convert components imports in web to be absolute
23 lines
614 B
TypeScript
23 lines
614 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import {
|
|
Comment,
|
|
listenForComments,
|
|
listenForRecentComments,
|
|
} from 'web/lib/firebase/comments'
|
|
|
|
export const useComments = (contractId: string) => {
|
|
const [comments, setComments] = useState<Comment[] | undefined>()
|
|
|
|
useEffect(() => {
|
|
if (contractId) return listenForComments(contractId, setComments)
|
|
}, [contractId])
|
|
|
|
return comments
|
|
}
|
|
|
|
export const useRecentComments = () => {
|
|
const [recentComments, setRecentComments] = useState<Comment[] | undefined>()
|
|
useEffect(() => listenForRecentComments(setRecentComments), [])
|
|
return recentComments
|
|
}
|