bill92B
tRPC2y ago
5 replies
bill92

conditional useQuery without input

How to use the enabled option for useQuery that doesn't has an input?

 const { isError, error } = trpc.iam.logout.useQuery(undefined, {
    enabled: isEnabled,
  });


I'm passing undefined and TS is not complaining, only on runtime I get

app-index.js:33 Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: [["iam","logout"],{"type":"query"}]

How to properly use this feature?
Was this page helpful?