jamesplease/react-request

change `fetching` to be set to `true` on mount for non-lazy requests

Open

#178 geöffnet am 25. Mai 2018

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (21 Forks)github user discovery
breakingenhancementhelp wanted

Repository-Metriken

Stars
 (358 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

I was wondering if you'd consider a slight change for non-lazy behavior. Right now it seems like you need to do:

<Fetch url="/me">
  {({ fetching, failed, data }) => {
    if (fetching) return ...
    if (failed) return ...
    if (!data) return null
    return ...
  }}
</Fetch>

There's an extra case where the component has just mounted, but hasn't yet started the request where fetching == false but data == null. Apollo seems to avoid this, such that you can handle the fetching and failed cases up front, and then assume you have data after that, which just reduces a little of the boilerplate.

Would you be down for that change?

Contributor Guide