Repeater with allowReordering logs React key and isDragging warnings

オープン 初心者向け
#419 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@s3rgiosan がすでに取り組んでいます。

2026年11月14日 から。

  • #420 @s3rgiosan による — オープン

評価

難易度
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):

  1. Warning: Each child in a list should have a unique "key" prop. Check the render method of SortableItem.
  2. Warning: React does not recognize the isDragging prop on a DOM element.

The cause:

  1. SortableItem calls cloneElement( repeaterItem, props, [ <DragHandle />, repeaterItem.props.children ] ). The children array has no keys.
  2. SortableItem passes isDragging to DragHandle. DragHandle spreads all its props onto a <span>, so isDragging gets to the DOM element.

Steps to Reproduce

  1. Load the block editor with the React development build (SCRIPT_DEBUG set to true).
  2. Render a repeater with reordering:
<AbstractRepeater allowReordering value={ [ { id: 'a' }, { id: 'b' } ] } onChange={ () => {} }>
	{ ( item, id ) => <div key={ id }>{ id }</div> }
</AbstractRepeater>
  1. Open the browser console. Both warnings show.

Expected behavior

The repeater renders without React warnings. The markup stays the same.

Environment information

  • @10up/block-components 1.23.0 and develop
  • React 18.3.1
主要言語
TypeScript
スター
330
フォーク
54
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

10up/block-components のほかの issue

10up/block-components の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。