You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Evaluate signed-zero equality for QueryObserver snapshots #12567
Evaluate whether QueryObserver snapshots should distinguish -0 from 0 when selected placeholder data changes. This is a follow-up for maintainers to decide the desired equality semantics; it does not assume that a global equality change is required.
Reproduction and current behavior
In the signed-zero regression case in packages/query-core/src/__tests__/queryObserver.test.tsx, create an observer with enabled: false, placeholderData: 1, structuralSharing: false, and a selector returning -0. Update the options to use a selector returning 0, then call getOptimisticResult with the updated options.
The PR author verified that the optimistic result contains 0, while getCurrentResult().data still contains -0. The shallow comparison treats these values as equal and preserves the current snapshot. The useQuery render in this case uses the optimistic result.
Decision and affected areas
Review the observer result comparison and update behavior in packages/query-core/src/queryObserver.ts and shallowEqualObjects in packages/query-core/src/utils.ts. Consider whether signed zeros should count as different, and whether any change should be local to observer results or use Object.is semantics more broadly. Assess effects on notifications, render optimizations, other equality cases such as NaN, and the useSyncExternalStore snapshot caching contract.
Acceptance criteria
Maintainers decide and document the intended signed-zero behavior for observer snapshots.
If a change is warranted, implement the chosen behavior without breaking snapshot stability or notification semantics.
If a change is made, add regression coverage for the chosen behavior, including the optimistic result and current snapshot, and cover any affected equality and notification behavior.
Activity