loading property returned by useFetchPosts isn't entirely accurate

Aperta
#843 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
next.js, react, typescript
Ambito
frontend

Direzione di ricerca

Inizia individuando useFetchPosts e confronta il suo calcolo dello stato di caricamento con il valore isLoading restituito da useFetch. Poi esamina il componente RelatedPosts in wp-nextjs-app per capire come gestisce lo stato di caricamento, i dati e NotFoundError. Il lavoro è completato quando lo stato di caricamento termina correttamente se non vengono trovati dati, senza compromettere il comportamento esistente del componente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
TypeScript
Stelle
204
Fork
26
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di 10up/headstartwp

Tutte le issue di 10up/headstartwp

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.