[Android/Fabric] setPageWithoutAnimation from useLayoutEffect is ignored when targeting a newly added page
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 58/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- android, react-native, typescript
- 領域
- mobile
調査の方向性
Start with the reproduction source’s App.tsx and the Android implementation of PagerView’s setPageWithoutAnimation command; trace how the command is handled when children are added. Compare the reported retry behavior with the command-only deferred patch in the archive. Done means the first request selects page D after adding pages, without a retry, and the existing pager behavior remains intact.
索引モデルが issue の本文から書いたものです。
説明
Description
Calling setPageWithoutAnimation(3) from useLayoutEffect immediately after expanding the pager from one page to four can leave the pager on page 0.
I reproduced this on a physical Android device using a standalone app with synthetic pages. The pager remains on page A for more than five seconds after requesting page D. Repeating the same command afterward switches to D successfully.
Environment
- react-native-pager-view: 9.0.7
- React Native: 0.88.0
- React: 19.3.0
- Architecture: Fabric
- Device: V2509A, physical device, arm64-v8a
- Android: 16 / API 36
- Build: Android debug native build with bundled JS (
dev=false), developer support disabled, no Metro connection
The baseline uses pager-view 9.0.7 with diagnostic logging only, without behavior-changing pager patches.
Steps to reproduce
- Render a
PagerViewcontaining only page A, withinitialPage={0}. - Wait for a nonzero layout and the initial
onPageSelectedevent reporting index 0. - Press Add pages & select D. This appends pages B, C, and D.
- In the
useLayoutEffectassociated with that update, callsetPageWithoutAnimation(3). - Observe that the pager remains on A.
- Wait several seconds, then press Retry select D, which repeats the same command without changing the children.
- The pager now switches to D and reports index 3.
The relevant update logic is:
const pager = useRef<PagerView>(null);
const [count, setCount] = useState(1);
useLayoutEffect(() => {
if (count === 4) {
pager.current?.setPageWithoutAnimation(3);
}
}, [count]);
// "Add pages & select D"
setCount(4);
// "Retry select D"
pager.current?.setPageWithoutAnimation(3);
The rendered children are PAGES.slice(0, count), with stable keys and collapsable={false}. The pager has a fixed positive height. No artificial mounting delays are introduced.
Expected behavior
The command selects the newly added page D once the corresponding child update has mounted, without requiring another command.
Actual behavior and device recording
https://github.com/user-attachments/assets/e859a058-98a2-4598-9d10-8374c806d5b8
In the baseline recording:
- At approximately 3.10 seconds, the React child count becomes 4 and the requested index is 3 (D), but the visible page and last
onPageSelectedvalue remain A / 0. - This mismatch persists for approximately 5.5 seconds.
- After pressing Retry select D, the visible page changes to D at approximately 8.58 seconds, and
onPageSelectedreports index 3 at approximately 8.60 seconds.
The “React children” counter reflects the React render state; it does not measure the number of children already mounted natively.
Command-only comparison
https://github.com/user-attachments/assets/77a4eb37-794d-4da9-ba99-dcec21c77830
I also tested a local change that defers command processing with View.post and validates the target index when the deferred command runs.
With that change, the same operation on the same device reaches D without pressing Retry. The comparison does not include measurement, page identity, or reattachment changes.
This supports a possible command-versus-child-mount timing issue. However, I could not obtain useful native logs from the device, so the exact native dispatch order has not been directly confirmed. The comparison demonstrates a fix for this reproduction, rather than establishing a complete solution for all command-ordering cases.
These recordings specifically test setPageWithoutAnimation; animated setPage was not tested on the device.
Reproduction source
The archive includes the tested App.tsx, build instructions, and the command-only comparison patch. Its README documents the build setup and verification scope.
- 主要言語
- TypeScript
- スター
- 3.4k
- フォーク
- 488
- 平均マージ
- 2日 2時間
- マージ済み PR(30日)
- 28
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
callstack/react-native-pager-view のほかの issue
-
[iOS] Focused TextInput keeps focus and keyboard after switching pages (v9)対応中かも @TaduJR が 6 日前に担当しました。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 69/100
callstack/react-native-pager-view#1192 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 73/100
callstack/react-native-pager-view#1191 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
callstack/react-native-pager-view#1189 ·
メンテナーはふだん 1 日以内に返信
-
iOS: PagerScrollDelegate proxies to itself and overflows the stack when the weak originalDelegate dies対応中かも @lvlrSajjad が 42 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
callstack/react-native-pager-view#1146 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
callstack/react-native-pager-view#1144 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
callstack/react-native-pager-view の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
openremote/openremote#3487 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
coollabsio/jean#867 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ehmpathy/rhachet-roles-bhuild#616 ·
メンテナーはふだん 1 日以内に返信
-
📘 Docs supabase/cli
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
bug(cli): theme file home-directory check uses startsWith (sibling dirs pass, Windows casing fails)オープンarea/core kind/bug priority/p2 status/bot-triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
google-gemini/gemini-cli#29955 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信