Disabling queries via ReactFireOptions
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- firebase, react, typescript
- Domain
- frontend
Research direction
The issue names ReactFireOptions and ObservableStatus as the relevant entry points; begin by tracing how the ReactFire hooks execute queries and expose status. Compare the proposed enabled behavior with the alternative exists status, including initialData handling. Done means dependent queries can avoid unintended execution or reliably determine reference existence without treating placeholder data as a result.
Written by the indexing model from the issue text.
Description
I've read the discussion in #178 and am yet another person that has run into the wall of "can't use the hooks with a not-yet-defined id". I understand and agree with your desire to keep undefined/null ids as errors. But we still run into situations where the use of react-fire hooks constrains our design decisions and requires us to make several small components that issue the same query when one query would do and would allow us to present the UI in a single component as we wish.
I suggest adopting something similar to how react-query handles this. Passing in an enabled flag to the ReactFireOptions object which would prevent the query from executing if enabled === false (and instead returning initialData, if defined). This would allow the errors to persist when inadvertently passing in undefined/null, but also allow consumers to make their own design decisions when constructing dependent queries.
Alternatively, add an exists property to the ObservableStatus so that we can determine, without an additional query, whether the ref already exists. Currently when I have a dependent query I pass in an ID that I know not to exist, e.g. "-1", but I get back a document that has a firestore-generated ID and nothing else. Without the ability to disable the query or determine if the ref exists I rely on the object being otherwise empty to determine if I should return an undefined or not.
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 403
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 11
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from FirebaseExtended/reactfire
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
FirebaseExtended/reactfire#801 ·
Maintainers usually reply within 2 days
-
v5
Difficulty 4/5 3-5 days Newbie friendliness 48/100
FirebaseExtended/reactfire#793 ·
Maintainers usually reply within 2 days
-
v5
Difficulty 4/5 3-5 days Newbie friendliness 35/100
FirebaseExtended/reactfire#790 · 2 comments ·
Maintainers usually reply within 2 days
-
v5
Difficulty 4/5 3-5 days Newbie friendliness 55/100
FirebaseExtended/reactfire#789 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
FirebaseExtended/reactfire#788 ·
Maintainers usually reply within 2 days
All issues in FirebaseExtended/reactfire
Similar issues
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mermaid-js/mermaid-live-editor#2053 ·
Maintainers usually reply within 1 day
-
factory
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jessepollak/home#1455 ·
Maintainers usually reply within 1 day
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
lingdojo/kana-dojo#31227 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
appandflow/stim#1838 ·
Maintainers usually reply within 1 day