MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
505 stars 58 forks source link

t.docChanges is not a function #85

Closed arminsal1 closed 5 years ago

arminsal1 commented 5 years ago

I get this error when I try to do onSnapshot on a GeoQuery:

t.docChanges is not a function. (In 't.docChanges()', 't.docChanges' is an instance of Array)

Here's my code:

let geoCollection = new GeoFirestore(firebase.firestore()).collection('activities');

   let query = geoCollection.near({
      center: new firebase.firestore.GeoPoint(location.latitude, location.longitude),
      radius: distanceInKm,
   });

  let activityQuery = query.onSnapshot((snapshot) => {
      console.log('Doc Changes', snapshot.docChanges());
  });

I'm using this with geofirestore 3.2.1 and react-native-firebase 5.1.0-rc2

MichaelSolati commented 5 years ago

RNFirebase isn't officially supported. The library is designed only for the official JS and Node Firebase libraries.

I would be open to adding support, in the future, but that is not currently a high priority.

MichaelSolati commented 5 years ago

@arminsal1 while I'm not planning on adding official support, I think I should at least be able to fix this problem. I'll need to throw together a quick app and do some testing (sorry for shutting this down so quickly).

ghost commented 5 years ago

+1 desperately need this as well

arminsal1 commented 5 years ago

@MichaelSolati Thanks for reopening, I appreciate you investigating the issue!

MichaelSolati commented 5 years ago

@arminsal1 && @teddyteh

Fun fact, my computer is being a pain in my @$$ and I can't actually throw together a little React Native app to run on either my Android device or my iPhone. 😅

Soooo... I'm gonna put it on you guys to help me out! (If you don't mind). If you can try installing this branch with a little tweak:

npm i geofirestore/geofirestore-js#fix/rnf

And let me know if anything/everything works for you. That would be much appreciated!

ghost commented 5 years ago

Not sure what's wrong but I'm getting this: "Non-registry package missing package.json: github:geofirestore/geofirestore-js#fix/rnf"

MichaelSolati commented 5 years ago

Hrmmm... Uhm, I guess try the following...

npm uninstall geofirestore
rm -rf node_modules
npm i
npm i geofirestore/geofirestore-js#fix/rnf
ghost commented 5 years ago

Weird. Same error still, is it cause I'm on windows and we're using unix commands like rm in the build script? npm ERR! prepareGitDep 2> npm WARN install Usage of the--devoption is deprecated. Use--only=devinstead. npm ERR! prepareGitDep node-pre-gyp WARN Using request for node-pre-gyp https download npm ERR! prepareGitDep node-pre-gyp WARN Using request for node-pre-gyp https download npm ERR! prepareGitDep 'rm' is not recognized as an internal or external command, npm ERR! prepareGitDep operable program or batch file. npm ERR! prepareGitDep npm ERR! code ELIFECYCLE npm ERR! prepareGitDep npm ERR! errno 1 npm ERR! prepareGitDep npm ERR! geofirestore@3.2.1 build:rm -rf ./dist && rollup -c npm ERR! prepareGitDep npm ERR! Exit status 1 npm ERR! prepareGitDep npm ERR! npm ERR! prepareGitDep npm ERR! Failed at the geofirestore@3.2.1 build script. npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! prepareGitDep npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in: npm ERR! prepareGitDep npm ERR! C:\Users\teddy\AppData\Roaming\npm-cache\_logs\2019-02-17T06_26_57_597Z-debug.log npm ERR! prepareGitDep npm ERR! code ELIFECYCLE npm ERR! prepareGitDep npm ERR! errno 1 npm ERR! prepareGitDep npm ERR! geofirestore@3.2.1 prepare:npm run build npm ERR! prepareGitDep npm ERR! Exit status 1 npm ERR! prepareGitDep npm ERR! npm ERR! prepareGitDep npm ERR! Failed at the geofirestore@3.2.1 prepare script. npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

MichaelSolati commented 5 years ago

Honestly, possibly... Like with the internal build commands. Here is a built dist folder, you'll just need to copy/replace the content of your node_module/geofirestore/dist folder with the content of the zip.

ghost commented 5 years ago

Cheers, seems to be working on react native finally! Tested onSnapShot() and that worked.

MichaelSolati commented 5 years ago

Version 3.2.2 is on its way to be deployed (I'm just letting Travis do it's thing). Try updating your package in an hour and you should be all set.

ghost commented 5 years ago

3.2.2 doesn't seem to have the fix, replacing the dist folder with the built version 3 comments above still works though

MichaelSolati commented 5 years ago

@teddyteh it should/is the same code... Would it be too much to ask for you to share with me a sample repo of it not working?

ghost commented 5 years ago

Does seem like this is working again unless it's something else. I'll see if it does it again.