Closed agumack closed 7 years ago
You can store everything in a list and then use the on("ready")
event to update state:
var keys = [];
var onKeyEnteredRegistration = geoQuery.on("key_entered", function (key, location, distance) {
console.log(key + " entered query at " + location + " (" + distance + " km from center)");
keys.push(key);
});
var onReadyRegistration = geoQuery.on("ready", function (key, location, distance) {
// Update state using the keys array
I cannot access this
inside of the geoQuery.on("ready"
function so when I use this.setState
in react native I get "cannot read property 'setState' of undefined ...
Okay if you run into the same problem I did in React-native, you will need to use an arrow function for the callback of the "ready" function like below. Also no point assigning variables to your functions
let requests_in_desired_redius = [];
geoQuery.on('key_entered', function(key, location, distance) {
requests_in_desired_redius.push({key, location, distance});
});
geoQuery.on('ready', () => {
this.setState({requests_in_desired_redius});
});
Hi guys,
Same title, how i can response all result query? Ex: var geoQuery = geoFire.query({ center: [10.38, 2.41], radius: 10.5 }).then((allResult)=>{ //some code })
I ask because i use geofire with react-native and have performance problem. my code:
thanks so much!!!