manifold/web/hooks/use-fold.ts
2022-01-23 00:51:19 -06:00

14 lines
342 B
TypeScript

import { useEffect, useState } from 'react'
import { Fold } from '../../common/fold'
import { listenForFold } from '../lib/firebase/folds'
export const useFold = (foldId: string) => {
const [fold, setFold] = useState<Fold | null | undefined>()
useEffect(() => {
return listenForFold(foldId, setFold)
}, [foldId])
return fold
}