invertase / invertase/tanstack-query-firebase

Uncaught ReferenceError: Cannot access 'query' before initialization

Open
#79 3 comments 0 reactions 0 assignees View on GitHub
react-query-firebase
Dominant language
TypeScript
Stars
462
Forks
69
PR merge metrics
No merged PRs in 30d

Description

I just tried the example at: https://react-query-firebase.invertase.dev/firestore/querying-collections
and got this error above.

If I move the query before the function it will work, but then I am not able to pass parameters to the querys where clause.

I am using React 16.14.0.

```
import React from "react";
import { useFirestoreQuery } from "@react-query-firebase/firestore";
import {
query,
collection,
limit,
QuerySnapshot,
DocumentData,
} from "firebase/firestore";
import { firestore } from "../firebase";

function Products() {
// Define a query reference using the Firebase SDK
const ref = query(collection(firestore, "products"));

// Provide the query to the hook
const query = useFirestoreQuery(["products"], ref);

if (query.isLoading) {
return

Loading...
;
}

const snapshot = query.data;

return snapshot.docs.map((docSnapshot) => {
const data = docSnapshot.data();

return

{data.name}
;
});
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.