reactjsrefine.js

useSelect data hook isLoading always returns false


I have the following code in a next-js page to create an address search autocomplete. I want to show a spinning circle to the user when the query is running, which can be quite slow.

import {useSelect} from "@refinedev/core";

 const {options: addressOptions, onSearch, queryResult} = useSelect<IAddress>({
        resource: `addresses/optionaladdresses/board/${id}`,
        hasPagination: false,
        optionLabel: "text",
        optionValue: "id",
        debounce: 500,
    });

    console.log(queryResult?.isLoading);

Why is the console always logging false?


Solution

  • Finally fixed after lots of frustration.

    Refine's useSelect builds on Trans Stack's useQuery which has an isFetching method.

    So it should be

    queryResult.isFetching