`shallow` doesn't correctly compare different object instances if they only have property getters
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start by locating the store's shallow implementation and its existing tests. Reproduce the reported comparison with two distinct objects that expose values through getters, then add coverage and adjust the behavior so distinct instances are not treated as equal; the relevant tests should pass afterward.
Written by the indexing model from the issue text.
Description
Describe the bug
I'm using @tanstack/react-form, but traced the issue back to the store here. Specifically, I'm trying to store Temporal.Duration values, but store updates are not being received via useStore because shallow returns true when both objects have no keys, i.e. Object.keys(objA) return [], instead of comparing referential equality at that point.
Steps to Reproduce the Bug or Issue
This, and any object factory that use getters instead of static properties return true.
shallow(Temporal.Duration.from({ hours: 1 }), Temporal.Duration.from({ days: 2 }));
Expected behavior
Expect to see false, since they are different values, different objects.
Screenshots or Videos
No response
Platform
- OS: macOS
- Browser: Arc (Chromium)
- Version: 138.0
Additional context
No response
- Dominant language
- TypeScript
- Stars
- 893
- Forks
- 114
- Avg merge
- 8d 14h
- Merged PRs (30d)
- 3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TanStack/store
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Missing atom docs Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·