Giter Club home page Giter Club logo

Comments (4)

ilyalesik avatar ilyalesik commented on May 25, 2024

Hey, @dohomi!

I think at most cases data exist check more useful that isLoading check. Also, we can use them both.

As en example,

const Component = () => {
  const { isLoading, data } = useFetch("...");

  if (!data || isLoading) {
    return <Spinner />
  }

  return <SomeOtherComponent {...data} />
};

What are you think about? Maybe it will fit your cases.

from react-fetch-hook.

dohomi avatar dohomi commented on May 25, 2024

@ilyalesik this is how I solve it now. I just thought there might be a usecase where data would be null|undefined|0 from the async call and then the Spinner would run forever.

For me its fine how it is now, I just thought the isLoading hook should initially always be true because the hook will always run initially. Then the data would not be needed to be called to check a loading spinner

from react-fetch-hook.

ilyalesik avatar ilyalesik commented on May 25, 2024

It sounds reasonable. I did isLoading=true by default since version v1.7.0.

from react-fetch-hook.

dohomi avatar dohomi commented on May 25, 2024

thanks 👍

from react-fetch-hook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.