ContentPicker SortableList logs a useSelect unstable value warning

Aperta
#421 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@s3rgiosan ci sta già lavorando.

Dal 14/11/2026.

  • #423 di @s3rgiosan — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
react, typescript, wordpress
Ambito
frontend, web-dev

Direzione di ricerca

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.

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

Descrizione

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
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.