ContentPicker SortableList logs a useSelect unstable value warning

オープン
#421 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@s3rgiosan がすでに取り組んでいます。

2026年11月14日 から。

  • #423 @s3rgiosan による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
react, typescript, wordpress
領域
frontend, web-dev

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
TypeScript
スター
330
フォーク
54
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

10up/block-components のほかの issue

10up/block-components の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。