parse-react
parse-react copied to clipboard
useParseQuery subscription
I'd like to request a feature / bug useParseQuery works good in mount/unmout scnearios, but with react-navigation they dont have this lifecycles so it is impossible to use useParseQuery
because it will keep requesting / updating other Screens, and I think with this will bring other level of customization, ex: click on somthing and being able to stop requesting live.
It could actually be a solution to use the enableLiveQuery
to start/stop at any time
Is it possible to change enableLiveQuery
on options and will it start / stop
The main objective is something like this
import { useIsFocused } from '@react-navigation/native';
import React,{ useEffect} from 'react';
// ...
function App() {
const isFocused = useIsFocused();
const {results,liveQuerySubscription} = useParseQuery(query);
useEffect(()=>{
if(!isFocused ){
// stop requesting
liveQuerySubscription.unsubscribe();
}
},[isFocused ])
return <Text>{isFocused ? 'focused' : 'unfocused'}</Text>;
}
But exporting the liveQuerySubscription
maybe would not be the greatest solution because when we return to the same srceen we, mount event will not be trigered and we want to start requesting again...
What you guys think would be the best solution?
should this work to stop / start live requesting on demand?
const isFocused = useIsFocused();
const {results} = useParseQuery(query,{enableLiveQuery :isFocused });
When I navigate between two screens it gives me this error on the console. I'm using useParseQuery
in both but for different requests.
https://user-images.githubusercontent.com/96492663/146973458-35fb7279-129f-4e43-b1d6-3674e0155c87.MOV
@claudiarsl Unfortunately, I have exactly the same problem. Were you able to solve the error somehow?