Description
I'd like to request a feature. It would be helpful to disable a query from running in some situations, until a condition is met.
I think adding an option enabled
to go alongside enableLocalDatastore
and enableLiveQuery
would do the trick.
The problem that I have is when using parse-react-ssr with Next.js (but using client-side only), when I use the next/router to get a document id from the query string, it can be undefined for a short time while the page loads. So I end up having to check if the id is not null:
const router = useRouter()
const projectId = router.query.projectId
const query = new Parse.Query('Project')
if (projectId) {
query.get(projectId)
}
const { results } = useParseQuery(query)
If there was an enabled
flag, then I could do this:
const { results } = useParseQuery(query, { enabled: !!projectId })
Another way this flag could be helpful is to allow a query to be dependent on another. For example, if we first needed to lookup the project before we could look up something dependent on the project.
What do you think?
Thanks!