R
Refine

ask-any-question

useSelect isLoading boolean

Ddependent-tan8/21/2023
Hi! Just wondering if useSelect returns an attribute representing whether it's loaded or not. (btw, I feel like I ask this question alot -- I've noticed the docs are outdated in this regard most of the time, since 1) the answer is usually yes, and 2) the method given in the docs is generally using overtimeOptions )
Kkapa.ai8/21/2023
Hi @avangeous. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The useSelect hook does not directly return a loading state. However, it does use the useList hook internally for fetching data, which might have a loading state. But this is not directly exposed by useSelect. However, in the context of Ant Design, the useSelect hook from the @refinedev/antd package does return a loading attribute. This is part of the selectProps returned by the hook, as shown in the following code snippet:
const { queryResult, defaultValueQueryResult, onSearch, options } =
useSelectCore(props);

return {
selectProps: {
options,
onSearch,
loading: defaultValueQueryResult.isFetching,
showSearch: true,
filterOption: false,
},
queryResult,
defaultValueQueryResult,
};
const { queryResult, defaultValueQueryResult, onSearch, options } =
useSelectCore(props);

return {
selectProps: {
options,
onSearch,
loading: defaultValueQueryResult.isFetching,
showSearch: true,
filterOption: false,
},
queryResult,
defaultValueQueryResult,
};
In this case, loading is set to defaultValueQueryResult.isFetching, which indicates whether the default value is being fetched. For more details, you can refer to the source code (https://refine.dev/blog/refine-react-invoice-generator-4) of useSelect inside the @refinedev/antd package. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Kkapa.ai8/21/2023
<@1122927158348763206> kapa.ai is still learning and improving, please let us know how it did by reacting below
Ddependent-tan8/21/2023
@kapa.ai Is there one that indicates whether the dropdown information is being fetched?
Kkapa.ai8/21/2023
Let me check the knowledge base for you. One moment! :books: ---------------------- The useSelect hook from the Mantine package in Refine returns a queryResult object, which is a QueryObserverResult from the react-query library. This object includes an isLoading property that indicates whether the query is currently fetching data. Here is the structure of the return values from useSelect:
| Property | Description | Type |
| --- | --- | --- |
| selectProps | Mantine Select props | **`SelectPropsType`** (<https://refine.dev/docs/api-reference/mantine/hooks/useSelect#selectpropstype>) |
| queryResult | Result of the query of a record | **`QueryObserverResult<{ data: TData }>`** (<https://react-query.tanstack.com/reference/useQuery>) |
| defaultValueQueryResult | Result of the query of a `defaultValue` record | **`QueryObserverResult<{ data: TData }>`** (<https://react-query.tanstack.com/reference/useQuery>) |
| defaultValueQueryOnSuccess | Default value onSuccess method | `() => void` |
| Property | Description | Type |
| --- | --- | --- |
| selectProps | Mantine Select props | **`SelectPropsType`** (<https://refine.dev/docs/api-reference/mantine/hooks/useSelect#selectpropstype>) |
| queryResult | Result of the query of a record | **`QueryObserverResult<{ data: TData }>`** (<https://react-query.tanstack.com/reference/useQuery>) |
| defaultValueQueryResult | Result of the query of a `defaultValue` record | **`QueryObserverResult<{ data: TData }>`** (<https://react-query.tanstack.com/reference/useQuery>) |
| defaultValueQueryOnSuccess | Default value onSuccess method | `() => void` |
You can check the isLoading property of the queryResult object to see if the dropdown data is being fetched. For more details, you can refer to the useSelect documentation (https://refine.dev/docs/api-reference/mantine/hooks/useSelect). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Kkapa.ai8/21/2023
<@1122927158348763206> kapa.ai is still learning and improving, please let us know how it did by reacting below
Aabsent-sapphire8/22/2023
Hey @avangeous useSelect makes a request to get the options. It returns queryResult. Here you can check queryResult.isLoading or queryResult.isFetched.

Looking for more? Join the community!

R
Refine

ask-any-question

Join Server
Recommended Posts
Calling reset() removes the whole value from fieldI have upgraded to refine 4 , I am using useForm for handling forms, for some reason when I am calliError With MUI InferencerWhen running Mui Inferencer, I am getting an error stating: ``` Exception: RangeError: Maximum calHas anyone gotten Airtable to work with a Personal Access Token?Hello, I'm just starting out and I'm having a hard time getting my app to work with Airtable; I'm cuconditional useSelectAs hooks can only be called at top level, is there any way possible to call useSelect hook only whenCombine Access Control of Refine with GetPermission API of strapiV4Is there any way to combine getPermission API of StrapiV4 with Access Control of Refine using RBAC. What parameter should I set to make mutate() optionally return the created data?I would like to create a new resource and navigate to the edit view for that resource. ``` refreshing useSelecthow to make useSelect refresh when a state variable is setHow to Handle Routes for Resources that are RelatedI have organizations that have many deployments and users, and deployments have many devices How soSetup Relationships Between Resources for InferencerSo my app has an organization resource and a deployment resource; deployments belong to an organizatErrors When Trying to Delete a ResourceOk, so in my List view, I added column actions for each row, where one of the actions is to delete tStrapi v4 Data Provider ExampleHello, I got problem with file uploading. I downloaded your example and made collection in strapi ad404 Error Create PageSo I created a new route for my organizations for the create resource: ``` { name: "organizations"How do I use `useEditableTable` with my own custom data fetcher/update logic?Essentially, I want to use the useEditableTable hook without a resource. I have backend call that caIs there any NX plugin to generate Refine templates in existing NX projects?Is there any NX plugin to generate Refine templates in existing NX projects?What type is error for onError within AuthProvider?I have an onError function in my custom authProvider.ts: ``` onError: async (error) => { consoleResource for "/"Hiya! I want to have a "home" page at the "/" route. For the life of me I cannot figure out how Redirect to resource/show/:id After Creating Said ResourceHello! I'd like to redirect the user to the newly-created resource after they've created it. How cWhy does my List page generate so many queries?This is my code for my list page (listing organizations): ``` import React from "react"; import { us