Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Query keys with object property set to undefined are not considered equal to missing property during invalidation

Đang mở
#3,741 15 bình luận 4 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
react, typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu với bản tái hiện CodeSandbox được liên kết và so sánh hành vi xác định đã được ghi lại của query-key với kết quả invalidation đối với các thuộc tính object bị thiếu và undefined. Truy vết các entry point của việc hashing và invalidation query-key, sau đó xác minh rằng cả hai query đều invalidate cùng một bản ghi trong bản tái hiện.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

package: react-query
Describe the bug

Query keys with object property set to undefined are not considered equal to missing property. Based on the docs, it should be the same: https://react-query.tanstack.com/guides/query-keys#query-keys-are-hashed-deterministically

Your minimal, reproducible example

https://codesandbox.io/s/react-query-trz8sx?file=/src/App.tsx

Steps to reproduce
  1. Open the codesandbox link
  2. Show codesandbox console
  3. There are two queries rendered, the first fetch all items, and the second fetch filtered ones.
  4. You can see two buttons with invalidation hooks. The first one invalidates both queries, the second one invalidates only non-filtered results. See the console for refetch logs.
Expected behavior

I expect both keys should invalidate the same records no matter of filter: undefined as mentioned in react-query docs.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

macOS v12.4
Chrome 103

react-query version

Both v3.39.1 and v4.0.0-beta.23

TypeScript version

v4.7.3

Additional context

No response

Ngôn ngữ chính
TypeScript
Star
50.4k
Fork
4.2k
Merge trung bình
13 giờ 33 phút
Pull request đã merge (30 ngày)
383

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/query

Tất cả issue của TanStack/query

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.