`useSelector` triggers `state_proxy_equality_mismatch` on every store update in svelte-store
まだ誰も着手していません。
評価
- 難易度
- 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.
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/store のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
Missing atom docs オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
-
`shallow` doesn't correctly compare different object instances if they only have property getters オープン
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
似ている issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100