headstartwp
headstartwp copied to clipboard
loading property returned by useFetchPosts isn't entirely accurate
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
- [X] I agree to follow this project's Code of Conduct