Skip to content
Source
Sign inSign up
TanStack/store

`shallow` doesn't correctly compare different object instances if they only have property getters #218

Opentcgj(GitHub profile, opens in a new tab) opened this issue 0 comments

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

Sign in to join this conversation.