ContentPicker SortableList logs a useSelect unstable value warning

Đang mở
#421 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@s3rgiosan đang làm issue này rồi.

Từ ngày 14/11/2026.

  • #423 của @s3rgiosan — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
42/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
react, typescript, wordpress
Lĩnh vực
frontend, web-dev

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
TypeScript
Star
330
Fork
54
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của 10up/block-components

Tất cả issue của 10up/block-components

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.