loading property returned by useFetchPosts isn't entirely accurate

Đang mở
#843 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
42/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Lĩnh vực
frontend

Hướng nghiên cứu

Bắt đầu bằng cách tìm useFetchPosts và so sánh cách tính trạng thái loading của nó với giá trị isLoading do useFetch trả về. Sau đó, kiểm tra component RelatedPosts trong wp-nextjs-app để hiểu cách nó xử lý loading, dữ liệu và NotFoundError. Hoàn thành khi trạng thái loading kết thúc chính xác trong trường hợp không tìm thấy dữ liệu mà không làm hỏng hành vi hiện tại của component.

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

Mô tả

breaking change
Is your enhancement related to a problem? Please describe.

When there is no data to return from useFetchPosts and a NotFoundError is returned instead, the loading property is still set to true.

For components that are relying on this property to display some sort of loading state, this can mean that they display that loading state indefinitely. An example of this can be seen in the RelatedPosts component of wp-nextjs-app.

https://share.zight.com/v1uq5KWZ

useFetch returns an accurate isLoading property to useFetchPosts, however, useFetchPosts does not use this and instead generates its own loading property. Components like RelatedPosts will then assume that if useFetchPosts isn't loading, it must have data. However, there is also the possibility that it is done loading and just has not found any data.

I'm not sure if we can change this behavior without breaking things since there may be components that are built with this existing behavior in mind, but it would be nice to be able to know if something is done loading, even if it doesn't return results.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct
  • I agree to follow this project's Code of Conduct
Ngôn ngữ chính
TypeScript
Star
204
Fork
26
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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 10up/headstartwp

Tất cả issue của 10up/headstartwp

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.