Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthrough
ChangesSelector state
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Possibly related PRs
Merge Risk: ⚪ Minimal · up to The selector change has no identified issue requiring a fix before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the motivation, implementation, and validation. It does not include the required Resolution Add the required template sections. Mark the contributing-guide and
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
packages/svelte-store/src/useSelector.svelte.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. packages/svelte-store/tests/ObjectRender.test.svelteESLint skipped: the matched ESLint configuration already failed (missing-dependency). packages/svelte-store/tests/index.test.tsESLint skipped: the matched ESLint configuration already failed (missing-dependency). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Sorry, dupe of #364 which just got merged |
Summary of Changes
In Svelte 5, using
$state(selector(source.get()))wraps any selected objects or arrays in deeply reactive proxies. This causes several issues when usinguseSelector:compare(slice, data)compares the reactive proxy inslicewith the raw object fromdata. Under default reference comparison (===), a Proxy never strictly equals the raw target object, causing false positives and triggering unnecessary updates on unaffected objects.state_proxy_equality_mismatchwarnings / errors in development when checking proxy vs raw object equality.storeVal.currentreceive a proxy rather than the raw object reference, defeating reference equality checks across component boundaries.This change switches
useSelector's internal state holder tolet slice = $state.raw(selector(source.get())). Because the selector state holder is updated via reassignment (slice = data),$state.rawretains full reactive signaling when values change while preserving reference identity and avoiding unwanted proxy wrapping.Validation
packages/svelte-storeensuring object reference identity is preserved and unchanged object selections do not trigger spurious re-renders.Summary by CodeRabbit
@tanstack/svelte-storeto preserve original object references and avoid unnecessary re-renders when unrelated store values change.