ContentPicker SortableList logs a useSelect unstable value warning

Abierto
#421 1 comentario 0 reacciones 0 asignados Ver en GitHub

@s3rgiosan ya está trabajando en esto.

Desde el 14/11/2026.

  • #423 de @s3rgiosan — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
react, typescript, wordpress
Área
frontend, web-dev

Línea de trabajo

Start in components/content-picker/SortableList.tsx, where the useSelect selector builds a new object per picked item and passes a new { _fields, context } query to getEntityRecord. Reproduce with globalThis.SCRIPT_DEBUG set to true, two core-store users, and mode="user", then check the console for the unstable-value warning. Done when the selector returns stable values and the warning no longer appears.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

When the editor runs with SCRIPT_DEBUG set to true, ContentPicker logs this warning after the picked items load:

The `useSelect` hook returns different values when called with the same state and parameters.
This can lead to unnecessary re-renders and performance issues if not fixed.

The useSelect selector in components/content-picker/SortableList.tsx causes the warning:

  1. The selector builds a new item object for each picked item on each call (posts.reduce(...)).
  2. The selector passes a new { _fields, context } query object to getEntityRecord on each call. With _fields in the query, getEntityRecord returns a filtered copy of the record. The selector cache uses the query object as a key, so a new query object gives a new copy.

Steps to Reproduce

  1. Set globalThis.SCRIPT_DEBUG to true. useSelect checks for unstable return values only in this mode.
  2. Put two records in the core store, for example two users.
  3. Render SortableList with mode="user" and the two users as posts.
  4. The useSelect warning shows in the console. The non-equal value keys are the uuid values of the picked items.

Expected behavior

The selector returns stable values, and ContentPicker logs no useSelect warning.

Environment information

  • @10up/block-components 1.23.0 and develop
Lenguaje dominante
TypeScript
Estrellas
330
Forks
54
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de 10up/block-components

Todos los issues de 10up/block-components

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.