Repeater with allowReordering logs React key and isDragging warnings

Aperta Adatta ai principianti
#419 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@s3rgiosan ci sta già lavorando.

Dal 14/11/2026.

  • #420 di @s3rgiosan — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
80/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Inizia dal percorso di rendering di SortableItem, dove cloneElement costruisce l'array dei children senza key, e dal componente DragHandle, che propaga tutte le sue props su uno span. Riproduci rendendo AbstractRepeater con allowReordering nella build di sviluppo (SCRIPT_DEBUG impostato a true) e osserva la console. Completato quando non compare nessuno dei due avvisi di React e il markup renderizzato è invariato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
330
Fork
54
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di 10up/block-components

Tutte le issue di 10up/block-components

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.