Repeater with allowReordering logs React key and isDragging warnings
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 80/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
- Área
- frontend
Línea de trabajo
Empieza por la ruta de renderizado de SortableItem, donde cloneElement construye el array de children sin keys, y por el componente DragHandle, que pasa todas sus props a un span. Reproduce el problema renderizando AbstractRepeater con allowReordering en el build de desarrollo (SCRIPT_DEBUG en true) y observa la consola. Terminado cuando no aparezca ninguna de las dos advertencias de React y el markup renderizado no cambie.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- TypeScript
- Estrellas
- 330
- Forks
- 54
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de 10up/block-components
-
ContentPicker SortableList logs a useSelect unstable value warningPosiblemente ocupada @s3rgiosan la tomó hace 5 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 42/100
10up/block-components#421 · 1 comentario ·
-
Subpath bundles duplicate PostContext, and the root import can't be tree-shakenPosiblemente ocupada @fabiankaegy la tomó hace 19 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
10up/block-components#417 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
10up/block-components#413 ·
-
Upgrading to React 19Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
10up/block-components#412 ·
-
ContentPicker: invalid htmlPosiblemente ocupada @s3rgiosan la tomó hace 5 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
10up/block-components#400 ·
Todos los issues de 10up/block-components
Issues similares
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 87/100
Los mantenedores suelen responder en 1 día
-
🛠️ dette technique
Dificultad 2/5 1-3 horas Aptitud para principiantes 61/100
betagouv/mon-entreprise#4752 · 1 comentario ·
Los mantenedores suelen responder en 5 días
-
type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
franciscoBSalgueiro/en-croissant#1111 ·
Los mantenedores suelen responder en 2 días
-
area/providers type/feature version/v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
anomalyco/opencode#64845 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día