rubber-blueR
Refine3y ago
5 replies
rubber-blue

useSelect typing when using optionLabel and optionValue

I am using useSelect with optionLable and optionValue as described here:
https://refine.dev/docs/api-reference/core/hooks/useSelect/#optionlabel-and-optionvalue

How to type useSelect when using Object path syntax?

   const { options, queryResult } = useSelect<IRevenueResponseResultOnly>({
      resource: "revenue",

      filters: [
         { field: "financialplan][id]", operator: "eq", value: selectedFinplan },
         { field: "resultsonly", operator: "eq", value: true },
      ],

      

      optionLabel: "revenuestream.base.name",
      optionValue: "revenuestream.basisangaben.id",

      queryOptions: {
         queryKey: ["revenue", selectedFinplan],
         enabled: selectedFinplan > 0 ? true : false,
      },
      
   })

optionLabel and optionValue give a typescript error:
Type '"revenuestream.basisangaben.name"' is not assignable to type 'keyof IRevenueResponseResultOnly'.ts(2322)
useSelect hook allows you to manage any select (like a Html `` tag, React Select, etc...) component. Since it is designed as headless, It expects you to handle the UI.
useSelect | refine
Was this page helpful?