[Suggestion]: clarify behaviour of ref callbacks
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Summary
The described behaviour for ref callbacks with null as an argument is ambiguous.
Page
https://react.dev/reference/react-dom/components/common#ref-callback
Details
From https://react.dev/reference/react-dom/components/common#ref-callback:
React will also call your ref callback whenever you pass a different ref callback. In the above example, (node) => { ... } is a different function on every render. When your component re-renders, the previous function will be called with null as the argument, and the next function will be called with the DOM node.
If I understand correctly, the emphasised sentenced is not correct when the ref callback returns a clean up function, as is the case in the referenced example. This needs to be clarified.
There is a note later on which helps a bit, but I still think this sentence could be made clearer so it makes sense in isolation.
Reduced test case to confirm this behaviour: https://stackblitz.com/edit/vitejs-vite-2r9rn6m2?file=src%2FApp.tsx&terminal=dev
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンク先のreact.devページのref-callbackセクションから始め、説明されている動作を検証するために、縮小したStackBlitzテストケースを確認してください。コールバックがクリーンアップ関数を返す場合にも正確であり続けるように強調表示された文を明確にし、後の注記に頼らなくても文意が通るようにしてください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 72/100