Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extra useQuery result frames #9599

Merged
merged 24 commits into from
Apr 18, 2022
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5a3f033
Added useQuery frame tests to show that there is an unneeded frame.
FritsvanCampen Mar 10, 2022
3d7fa34
Strengthen frame tests with expected NetworkStatus values.
benjamn Mar 22, 2022
7f98827
TODOs
benjamn Mar 21, 2022
6540b23
Call this.observable.setOptions when options change in useOptions.
benjamn Mar 22, 2022
a90922c
Fix lifecycle test extraneous results.
benjamn Mar 22, 2022
95a1749
Fix faulty skip tests.
benjamn Mar 22, 2022
9b03177
Improve mutation test timing robustness.
benjamn Apr 7, 2022
7e723db
Support WatchQueryOptions.fetchBlockingPromise.
benjamn Apr 14, 2022
7b80c93
Use fetchBlockingPromise when calling setOptions.
benjamn Apr 14, 2022
db0bd4b
Fix skip tests previously suffering from extraneous results.
benjamn Apr 14, 2022
85ae61f
Correct the frame test.
benjamn Apr 13, 2022
655fe74
Make the corrected frame test pass.
benjamn Apr 14, 2022
2101a72
Make other tests pass.
benjamn Apr 14, 2022
e94b545
Remove UNNEEDED_FRAME from useQuery tests.
benjamn Apr 14, 2022
d0265d4
Remove non-essential code (no tests fail).
benjamn Apr 14, 2022
a506feb
Use fetchBlockingPromise for initial useQuery request as well.
benjamn Apr 14, 2022
d047ab1
Decompose and reuse useUnblockFetchEffect helper function.
benjamn Apr 14, 2022
6033827
Silently discard blocked fetches after five seconds without useEffect.
benjamn Apr 14, 2022
7331572
Call this.observable.reobserve directly, instead of setOptions.
benjamn Apr 14, 2022
4ba569e
Bump bundlesize limit to 29.4kB (now 29.35kB).
benjamn Apr 14, 2022
b992e37
Reduce RenderPromises clutter in useQuery implementation.
benjamn Apr 15, 2022
c402dd4
Handle fetchBlockingPromise rejections more gracefully.
benjamn Apr 18, 2022
241f6ee
Basic tests of using options.fetchBlockingPromise directly.
benjamn Apr 18, 2022
58cab4e
Test fetchBlockingPromise prevents duplicate requests in <StrictMode>.
benjamn Apr 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove non-essential code (no tests fail).
  • Loading branch information
benjamn committed Apr 14, 2022
commit d0265d4c3270ac6d93eb8001a4ab4e31dbaa9fcb
16 changes: 1 addition & 15 deletions src/react/hooks/useQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ class InternalState<TData, TVariables> {
// allows us to depend on the referential stability of
// this.watchQueryOptions elsewhere.
const currentWatchQueryOptions = this.watchQueryOptions;
const originalResult = this.result;
let resolveFetchBlockingPromise: undefined | ((result: boolean) => any);

if (!equal(watchQueryOptions, currentWatchQueryOptions)) {
Expand Down Expand Up @@ -250,23 +249,10 @@ class InternalState<TData, TVariables> {
}

useEffect(() => {
// If we called this.observable.reobserve above, and this.result hasn't
// changed since then, report the latest current result to this.setResult.
if (resolveFetchBlockingPromise) {
resolveFetchBlockingPromise(true);

// If we set this.result to void 0 above, we still need to call
// this.setResult with the new result (but here in useEffect, since
// setResult typically calls forceUpdate), assuming latestResult is
// different from what we started with.
if (!this.result) {
const latestResult = this.getCurrentResult();
if (!equal(latestResult, originalResult)) {
this.setResult(latestResult);
}
}
}
}, [resolveFetchBlockingPromise, originalResult]);
}, [resolveFetchBlockingPromise]);

this.ssrDisabled = !!(
options.ssr === false ||
Expand Down