Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loading property returned by useFetchPosts isn't entirely accurate #843

Open
1 task done
sambrodie opened this issue Aug 7, 2024 · 1 comment
Open
1 task done

Comments

@sambrodie
Copy link
Contributor

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
@nicholasio
Copy link
Member

Good catch, this isn't specific to App Router but I agree we need to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants