SectionList ListHeaderComponent gets rerendered when sections data changes
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 4
説明
🐛 Bug Report
This is a duplicate of:
https://github.com/facebook/react-native/issues/16824
https://github.com/facebook/react-native/issues/16823
https://github.com/facebook/react-native/issues/14249
But since those 3 were closed and they are missing a reproducible example of the bug I'm reopening.
Description
If one uses a TextInput as a ListHeaderComponent when searching and when the returned sections are empty the TextInput loses focus.
If when searching the sections still have data - then the TextInput in the ListHeaderComponent doesn't lose focus.
To Reproduce
https://snack.expo.io/H12h3BgHV
Expected Behavior
I would expect for the TextInput not to lose focus
Code Example
https://snack.expo.io/H12h3BgHV
Environment
[skip envinfo]
RN 0.58
I've been trying to debug this with @pawelczerepak and what we noticed is that VirtualizedCellWrapper
https://github.com/facebook/react-native/blob/master/Libraries/Lists/VirtualizedList.js#L1759
gets unmounted and mounted when sections is an empty array. And when this happens everything inside of it gets unmounted and mounted again.
@sahrens - any ideas on what might be going on here?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Snack の例でフォーカスが失われる現象を再現し、その後、Libraries/Lists/VirtualizedList.js の 1759 行目付近にある VirtualizedCellWrapper のコードを調べてください。sections が空になったときに、それがアンマウントされて再度マウントされる理由を追跡し、セクションデータが変化している間も ListHeaderComponent の TextInput にフォーカスが維持されることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- react-native
- 領域
- mobile
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100