Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`useSelector` triggers `state_proxy_equality_mismatch` on every store update in svelte-store

オープン 初心者向け
#322 コメント 2 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
frontend

調査の方向性

packages/svelte-store/src/useSelector.svelte.ts の示されている比較分岐から始め、リンク先の Svelte Playground または報告された @tanstack/svelte-table のセットアップで警告を再現します。slice、data、defaultCompare の相互作用を確認します。state_proxy_equality_mismatch 警告がなくなり、store の更新時に比較が正しく動作すれば完了です。

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

説明

Describe the bug

In useSelector, slice is Proxied via $state, whereas the data resolved through selector(s) is not Proxied.

Because of this, the comparison performed by compare function (where defaultCompare is used) triggers Svelte's state_proxy_equality_mismatch warning. This causes the comparison to always return false, making this conditional branch a kind of dead code.

https://github.com/TanStack/store/blob/a378a51fa53af899dec1c146933d037a2811a86e/packages/svelte-store/src/useSelector.svelte.ts#L37-L50

Steps to Reproduce the Bug or Issue

It is easiest to try out @tanstack/svelte-table v9 alpha to understand it better.

Here is the demo in Svelte Playground.
https://svelte.dev/playground/6cb4726d28594a3a9781f8a785d331fe?version=latest

<script lang="ts">
  import { createTable, tableFeatures } from '@tanstack/svelte-table';

  const _features = tableFeatures({});
  let data = $state([{ id: 1 }]);
  const table = createTable({
    _features,
    _rowModels: {},
    get data() { return data; },
    columns: [{ accessorKey: 'id', header: 'ID' }],
  });
</script>

<button onclick={() => (data = [...data, { id: data.length + 1 }])}>Add</button>
{#each table.getRowModel().rows as row (row.id)}
  <div>{row.original.id}</div>
{/each}
Expected behavior

Fix this warning so the comparison works right.

Screenshots or Videos

No response

Platform
  • @tanstack/svelte-store@0.12.0
    • @tanstack/svelte-table@9.0.0-alpha.45
  • svelte@5.55.x
Additional context

It will probably be resolved just by changing slice variable $state to $state.raw.
This is because the slice reassigning the entire variable, so there seems to be no reason to make it a Proxy.

主要言語
TypeScript
スター
893
フォーク
114
平均マージ
8日 14時間
マージ済み PR(30日)
3

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

TanStack/store のほかの issue

TanStack/store の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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