PanResponder.create() API either loses state or has stale state
まだ誰も着手していません。
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 4
説明
Description
PanResponder has a bunch of private state. This means it's not safe to re-create during a gesture: that state would be lost. This means that it's important to keep a ref to PanResponder which is what the docs seem to suggest.
However, holding a ref to it is bad because all the props and state captured by handlers will be stale. To fix this, you have to either update parts of that ref manually, or to recreate the PanResponder instance (which, as mentioned earlier, will reset its state — which seems bad).
I think this says that PanResponder.create API is not a good API for Hooks and need to be revisited. E.g. maybe it should be a Hook like usePanResponder(config) which takes care of updating the appropriate event handlers as needed — or maybe implemented with useRef inside. The important part is that the handlers should always be fresh (and capture fresh values), while the internal state of the gesture recognizer should never be destroyed.
React Native Version
any version
Output of npx react-native info
irrelevant
Steps to reproduce
irrelevant
Snack, screenshot, or link to a repository
irrelevant
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
packages/react-native/Libraries/Interaction/PanResponder.js から始め、特に issue で説明されている private state と PanResponder.create API を確認し、ドキュメント化された PanResponder の使用パターンと比較します。ジェスチャーの状態を破棄せずにハンドラーが最新の値を受け取る方法を明らかにします。完了条件は、状態の保持とハンドラーの鮮度の両方について、合意された API の方向性とそれに対応する動作が定まっていることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react-native
- 領域
- mobile
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100