react / react/react-native

Using useDeferredValue and Suspense unexpectedly shows fallback in ios/android but correctly shows stale state in web

オープン
#50,078 コメント 8 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs: Attention
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
4

説明

Description

I'm following the examples from React on using useDeferredValue and Suspense to show a stale state. The correct behavior should be to show the fallback only on the first load, and then on subsequent queries (e.g. when typing in the search box or incrementing counter in the examples) show a stale state until new data is loaded (which then should replace the stale state). I've included an expo snack.

The correct behavior is observed in React Native web. However for android/ios the fallback always shows. For the snack I'm using React Native 0.76.7, which is the default version that a new expo project installs. I've also tested on 0.77.1 but get the same behavior.

In my actual project where I have ios/android folders I've tried explicitly setting newArchEnabled/isConcurrentRootEnabled like some of these older articles suggest, see here. However, the same behavior is observed with that as well.

Steps to reproduce
  1. Go to the expo snack https://snack.expo.dev/@polarwang/reactnative-suspense-usedeferredvalue-bug
React Native Version

0.76.7

Affected Platforms

Other (please specify)

Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
  OS: macOS 15.2
  CPU: (16) arm64 Apple M3 Max
  Memory: 3.03 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.9.0
    path: ~/.nvm/versions/node/v20.9.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.9.0/bin/yarn
  npm:
    version: 10.1.0
    path: ~/.nvm/versions/node/v20.9.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.2
      - iOS 18.2
      - macOS 15.2
      - tvOS 18.2
      - visionOS 2.2
      - watchOS 11.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23339.11.2421.12700392
  Xcode:
    version: 16.2/16C5032a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: javac 22
    path: /Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 18.0.0
    wanted: latest
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.7
    wanted: 0.76.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.78.0 is now available (your project is running on v0.76.7).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.78.0
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.76.7&to=0.78.0
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
There is no stacktrace but the behavior is illustrated in the snack
Reproducer

https://snack.expo.dev/@polarwang/reactnative-suspense-usedeferredvalue-bug

Screenshots and Videos

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた Expo Snack の再現例から始め、React Native iOS/Android の動作と React Native web を比較します。issue に記載された useDeferredValue と Suspense の例のフローを確認し、その後、ネイティブでは初回ロード時にのみ fallback が表示され、後続のクエリでは古いコンテンツが表示されることを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react-native
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。