UseCollectionData wrong type (TS2345)
See original GitHub issueHello, now with the new version i get the following error - in V2.2.0 it works:
TS2345: Argument of type ‘DocumentReference<DocumentData>’ is not assignable to parameter of type ‘Query<FirebaseCourse>’. Type ‘DocumentReference<DocumentData>’ is missing the following properties from type ‘Query<FirebaseCourse>’: where, orderBy, limit, limitToLast, and 4 more.
code:
const [coursesData] = useCollectionData<FirebaseCourseWithUid>(
firebase.firestore().collection('courses'),
{ idField: 'uid' }
);
FirebaseCourseWithUid:
export type FirebaseCourseWithUid = {
title: string;
description: string;
start: string;
duration: number;
recurrence: { daysOfWeek: Array<number>; weekInterval: number } | null;
trainerId: string;
imageUrl: string;
isOnline: boolean;
uid: string;
};
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Argument of type '"==="' is not assignable to parameter of type ...
But the program won't compile and gives the following error: ... error TS2345: Argument of type '"==="' is not assignable to parameter of ......
Read more >TypeScript – When a data type is not assignable to itself ...
src/plugin/visitors/flow.ts:59:22 - error TS2345: Argument of type 'TSTypeAliasDeclaration' is not assignable to parameter of type 'AnyTypeAnnotation ...
Read more >react-firebase-hooks - npm
A set of reusable React Hooks for Firebase. npm version npm downloads. This documentation is for v5 of React Firebase Hooks which requires ......
Read more >React bindings for Firebase | Authentication library - kandi
useCollectionData returns undefined in react-firebase-hooks ... Firebase onSnapshot in react error, "Expected type 'bc', but it was: a custom he ...
Read more >Using Firestore With Typescript - Medium
What if I get the type wrong? More code to write etc. etc. Something else that gives me the chills is having to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having the same issue since upgrading to v3. Here’s a simple example.
This throws the following type error.
It seems that removing the generic from
firebase.firestore.Query
does the trick, but I’m not sure what type features this then loses. I’m guessing that generic perhaps adds types into thewhere()
method, but unsure.https://github.com/CSFrequency/react-firebase-hooks/blob/master/firestore/useCollection.ts#L34
Hey. Thank you for your quick reply. Im also on
firebase@8.2.9