ContentPicker SortableList logs a useSelect unstable value warning
Đá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
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:
- The selector builds a new item object for each picked item on each call (
posts.reduce(...)). - The selector passes a new
{ _fields, context }query object togetEntityRecordon each call. With_fieldsin the query,getEntityRecordreturns 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
- Set
globalThis.SCRIPT_DEBUGtotrue.useSelectchecks for unstable return values only in this mode. - Put two records in the
corestore, for example two users. - Render
SortableListwithmode="user"and the two users asposts. - The
useSelectwarning shows in the console. The non-equal value keys are theuuidvalues of the picked items.
Expected behavior
The selector returns stable values, and ContentPicker logs no useSelect warning.
Environment information
@10up/block-components1.23.0 anddevelop
- 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
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của 10up/block-components
-
Repeater with allowReordering logs React key and isDragging warningsCó thể đã có người làm @s3rgiosan đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
10up/block-components#419 · 1 bình luận ·
-
Subpath bundles duplicate PostContext, and the root import can't be tree-shakenCó thể đã có người làm @fabiankaegy đã nhận 19 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
10up/block-components#417 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
10up/block-components#413 ·
-
Upgrading to React 19Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
10up/block-components#412 ·
-
ContentPicker: invalid htmlCó thể đã có người làm @s3rgiosan đã nhận 5 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
10up/block-components#400 ·
Tất cả issue của 10up/block-components
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
Maintainer thường phản hồi trong vòng 1 ngày
-
🛠️ dette technique
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
betagouv/mon-entreprise#4752 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
-
type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
franciscoBSalgueiro/en-croissant#1111 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area/providers type/feature version/v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
anomalyco/opencode#64845 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày