I am trying to use geofirestore to get from the documents of a collection those that are a certain distance from the user's location in a react native Cli application, when trying to implement geofirestore I get the following TypeError:
error: _$$_REQUIRE(_dependencyMap[9 ], "(...)estore").GeoFirestore.collection is not a function (it is undefined), could you help me solve this problem please
note: the implementation of firestore is correct since I have other methods where documents from firestore collections are obtained correctly, I only get the error with the implementation of geofirestore
These are the versions that are installed in the project
"firebase": "^9.23.0",
"geofirestore": "^5.2.0",
this is my firebase configuration file
import { initializeApp } from 'firebase/app';
import { getAuth } from 'firebase/auth';
import { getFirestore } from 'firebase/firestore';
import { GeoFirestore } from 'geofirestore';
const firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
};
const app = initializeApp(firebaseConfig);
const authentication = getAuth(app);
const db = getFirestore(app);
const geofirestore = new GeoFirestore(db);
export { app, authentication, db, geofirestore };
and this is my file where I implement geofirestore
import { useNavigation } from "@react-navigation/native";
import { useEffect, useState } from "react";
import GetLocation from 'react-native-get-location'
import { collection, onSnapshot, orderBy, query, where, getDocs } from "firebase/firestore";
import { db } from "../../utils/keys"
import { getAuth } from "firebase/auth";
import { GeoFirestore } from 'geofirestore';
const obtenerRegistrosCercanos = async () => {
const eventosCollection = GeoFirestore.collection(db,'eventos');
const center = new firestore.GeoPoint(19.325471, -99.656188);
const radius = 10;
const query = eventosCollection.near({
center,
radius,
});
query.get().then((snapshot) => {
snapshot.docs.forEach((doc) => {
const data = doc.data();
console.log(data);
});
});
};