Repeater with allowReordering logs React key and isDragging warnings
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 80/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
- 領域
- frontend
調査の方向性
SortableItem のレンダリング経路から始めます。そこでは cloneElement が key なしで children 配列を構築しています。また DragHandle コンポーネントも確認してください。これはすべての props を span に展開しています。開発ビルド(SCRIPT_DEBUG を true に設定)で allowReordering を指定して AbstractRepeater をレンダリングし、コンソールを確認して再現します。React の警告が2つとも出ず、レンダリングされたマークアップが変わらなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
When allowReordering is on, the Repeater and AbstractRepeater components log two React warnings in development mode (for example, with SCRIPT_DEBUG set to true):
Warning: Each child in a list should have a unique "key" prop. Check the render method of SortableItem.Warning: React does not recognize the isDragging prop on a DOM element.
The cause:
SortableItemcallscloneElement( repeaterItem, props, [ <DragHandle />, repeaterItem.props.children ] ). The children array has no keys.SortableItempassesisDraggingtoDragHandle.DragHandlespreads all its props onto a<span>, soisDragginggets to the DOM element.
Steps to Reproduce
- Load the block editor with the React development build (
SCRIPT_DEBUGset totrue). - Render a repeater with reordering:
<AbstractRepeater allowReordering value={ [ { id: 'a' }, { id: 'b' } ] } onChange={ () => {} }>
{ ( item, id ) => <div key={ id }>{ id }</div> }
</AbstractRepeater>
- Open the browser console. Both warnings show.
Expected behavior
The repeater renders without React warnings. The markup stays the same.
Environment information
@10up/block-components1.23.0 anddevelop- React 18.3.1
- 主要言語
- TypeScript
- スター
- 330
- フォーク
- 54
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
10up/block-components のほかの issue
-
ContentPicker SortableList logs a useSelect unstable value warning対応中かも @s3rgiosan が 5 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
10up/block-components#421 · コメント 1 件 ·
-
Subpath bundles duplicate PostContext, and the root import can't be tree-shaken対応中かも @fabiankaegy が 19 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
10up/block-components#417 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
10up/block-components#413 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
10up/block-components#412 ·
-
ContentPicker: invalid html対応中かも @s3rgiosan が 5 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
10up/block-components#400 ·
10up/block-components の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 87/100
メンテナーはふだん 1 日以内に返信
-
🛠️ dette technique
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
betagouv/mon-entreprise#4752 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信
-
type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
franciscoBSalgueiro/en-croissant#1111 ·
メンテナーはふだん 2 日以内に返信
-
area/providers type/feature version/v2
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
anomalyco/opencode#64845 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信