fix(infinite): keep parallel getKey previousPageData null on setSize#4253
Open
li-jia-nan wants to merge 3 commits into
Open
fix(infinite): keep parallel getKey previousPageData null on setSize#4253li-jia-nan wants to merge 3 commits into
li-jia-nan wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes useSWRInfinite key recomputation during setSize when parallel: true, ensuring getKey continues to receive previousPageData = null (since pages are independent in parallel mode). It also adds a regression test to prevent key mismatches between the initial parallel load and subsequent setSize calls.
Changes:
- Update
setSizeto callgetKey(i, null)inparallelmode and avoid updatingpreviousPageData. - Tighten typing for internal arrays used during parallel revalidation.
- Add a regression test covering
setSizebehavior withparallel: true.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/infinite/index.ts |
Adjusts setSize page-key recomputation to respect parallel semantics (no previousPageData). |
test/use-swr-infinite.test.tsx |
Adds a regression test intended to assert previousPageData remains null after calling setSize in parallel mode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When useSWRInfinite runs with parallel enabled, getKey should always receive null as previousPageData because pages are independent. setSize previously recomputed page keys using the previous page data, which could produce keys inconsistent with the initial parallel load.
Update setSize to pass null in parallel mode and add a regression test.