rustclanR
tRPC3y ago
7 replies
rustclan

return type of a query endpoint

Hello

I currently have a trpc endpoint:
  const customInstances = api.customInstance.userCustomInstances.useQuery();


And I am trying to pass this into a custom react component:
interface CustomInstanceProps {
  customInstances: any;
}

const CustomInstance = ({customInstances}: CustomInstanceProps) {
  const data = customInstances.data;
  const refetch = () => {customInstances.refetch()}
   
  return (
  <Button onClick={() => {
    refetch()
   }}>refetch data</Button>
)
}

The problem is, I'm not entirely sure how I am supposed to type the customInstance property? I have tried using return types:
  customInstances: ReturnType<
    typeof api.customInstance.userCustomInstances.useQuery
  >;

but this makes the
data
property value
unknown
.
image.png
Was this page helpful?