Skip to content

isLoading false by default #144

@benmonro

Description

@benmonro

It seems to me that isLoading should be true by default.

If you have the following:

const MyComponent = () => {
   const {isLoading, data} = useQuery("todos", fetchTodos);

   if(isLoading) {
        return <Spinner />;
   }
   if(!data) {
        return "You don't have any todos";
   }
   return <div>Your todos: {data}</div>
}

Currently in with this code you will see a flash of "you don't have any todos", followed by the spinner, followed by Your todos: foo. We want our UX to be just followed by the data, w/out the flash of empty data content first.

As far as I could tell there's nothing in the api that allows you to set the initial state to 'isLoading' to be true. Is there any way to accomplish this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions