geofire-js | GeoFire for JavaScript - Realtime location queries | Authentication library
kandi X-RAY | geofire-js Summary
kandi X-RAY | geofire-js Summary
GeoFire for JavaScript - Realtime location queries with Firebase
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of geofire-js
geofire-js Key Features
geofire-js Examples and Code Snippets
// Install from NPM. If you prefer to use a static .js file visit
// https://github.com/firebase/geofire-js/releases and download
// geofire-common.min.js from the latest version
npm install --save geofire-common
Community Discussions
Trending Discussions on geofire-js
QUESTION
Is there a way to avoid update a callback in useEffect?. For example I am subscribed an event with geofire, this listens for changes and receive locations.
I need to update my state without subscribing every time on every update.
Current behavior- Subscribed to geofire and receive location (A)
- Update my state with the new location (A)
- Subscribed to geofire again and receive location (A)
this is an infinite loop. And I can't receive the other locations
Expected behavior- subscribed to geofire only once and receive locations (A,B,C)
- update my state with the new locations (A,B,C)
ANSWER
Answered 2020-Jun-29 at 02:25Have you checked if the return conditional is working on page load (just put a console log in there)?
From reading it, it seems both useEffects get called on page load, but the second one should exit immediately, and then get called again after the first one completes.
Then I notice you update state through an async call back, which may have something to do with it. It's difficult to say without seeing it in action.
I would say try rewriting your setCurrentLocation with a function rather than object:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install geofire-js
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page