Bug
1. useRxDocument first paint looks like "not found"
https://github.com/pubkey/rxdb/blob/master/src/plugins/react/hooks/use-rx-document.ts
const [result, setResult] = useState(null);
const [loading, setLoading] = useState(false); // should be true when a key is set
setLoading(true) runs only in useEffect. The first committed paint is loading: false and result: null. Callers that check loading before treating null as missing still get a false miss on that frame. Going from no key to a key has the same first paint.
#8292 / #8294 set initial loading: true for useRxQuery / useLiveRxQuery only. useRxDocument (#8272) still starts false.
2. Query or key change commits the previous result as settled
On query / primaryKey change, both useLiveRxQuery and useRxDocument keep the previous results / result with loading: false for one committed render. setLoading(true) in useEffect is too late.
Expected
useRxDocument: loading is true whenever a key is set and the current key has not emitted yet.
- After a query or key change, the first committed paint must not present the previous result with
loading: false.
Related
Is there a reason or convention behind this behavior? Many other react-hook libraries instead use a pretty aggressive loading: true state before things are resolved. I think Apollo's model is reasonably informative, especially with extended network statuses.
Bug
1.
useRxDocumentfirst paint looks like "not found"https://github.com/pubkey/rxdb/blob/master/src/plugins/react/hooks/use-rx-document.ts
setLoading(true)runs only inuseEffect. The first committed paint isloading: falseandresult: null. Callers that checkloadingbefore treatingnullas missing still get a false miss on that frame. Going from no key to a key has the same first paint.#8292 / #8294 set initial
loading: trueforuseRxQuery/useLiveRxQueryonly.useRxDocument(#8272) still startsfalse.2. Query or key change commits the previous result as settled
On
query/primaryKeychange, bothuseLiveRxQueryanduseRxDocumentkeep the previousresults/resultwithloading: falsefor one committed render.setLoading(true)inuseEffectis too late.Expected
useRxDocument:loadingistruewhenever a key is set and the current key has not emitted yet.loading: false.Related
loading: truefor list queries onlyIs there a reason or convention behind this behavior? Many other react-hook libraries instead use a pretty aggressive
loading: truestate before things are resolved. I think Apollo's model is reasonably informative, especially with extended network statuses.