-
Notifications
You must be signed in to change notification settings - Fork 306
Closed
Description
react-firebase-hooks rocks, btw -- thanks!
slight (trivial) suggestion:
// current
export const useDocument = (
docRef?: firestore.DocumentReference | null,
// proposed
export const useDocument<T = firestore.DocumentData> = (
docRef?: firestore.DocumentReference<T> | null,
this would also apply to useCollection
, etc.
This would be helpful because firestore does indeed preserve the type all the way to the subsequent snapshot data()
value.
As a side-benefit, a typed ref
would improve the useDocumentData
API allowing you to deduce the returned data type without the explicit generic:
// current
const [data, loading, error] = useDocumentData<MyData>(ref);
// becomes (optional, if your ref happens to be typed)
const [data, loading, error] = useDocumentData(myDataRef); // myDataRef is DocumentReference<MyData>
ps: best practice would still be to validate the payload with yup
etc. but this would go a long way!
Metadata
Metadata
Assignees
Labels
No labels