Skip to content

fix: react.use should not depend on data condition #4150

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Jul 29, 2025

Fix SWR's incorrect usage of React's use() hook and update tests for React 19

Problem

SWR currently uses React's use() hook incorrectly in the suspense implementation, which causes incorrect data to be displayed in Suspense scenarios. This is particularly problematic with React 19's improved concurrent features and stricter use() hook behavior.

Reference: SWR's incorrect use() implementation

React side changes:
x-ref: facebook/react#34030

Changes

  • Always call use() in render unconditionally when suspense flag is enabled
  • Migrate a unit test to e2e tests for suspense case as the UT can't cover it easily
  • Upgrade Next.js and react setup for e2e test

Copy link

codesandbox-ci bot commented Jul 29, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@huozhi huozhi force-pushed the fix/react-use branch 2 times, most recently from 48bcc49 to f18bb0c Compare July 29, 2025 10:27
Copy link

socket-security bot commented Jul 30, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednext@​13.5.11 ⏵ 15.4.482 +4100 +3090 -39870

View full report

@huozhi huozhi marked this pull request as ready for review July 30, 2025 22:31
@huozhi huozhi requested a review from shuding as a code owner July 30, 2025 22:31
@huozhi huozhi requested a review from sebmarkbage July 30, 2025 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant