Hello,
thank you for a library,
I'm actually struggling to find a way to call trpc useSwr hook conditionnaly.
Based on the docs, with useSwr, we could do something like:
const { data } = useSWR(shouldFetch ? '/api/data' : null, fetcher)
But I don't see any examples with trpc.useSwr and I have typescript errors than I use the syntax like:
trpc.useSWR(shouldFetch ? ['api.data'] : null)
Type 'null' is not assignable to type ... which is expected type error as null is not a part of AppRouter procedures
Is there a way to do it? Am I doing something wrong?
Thanks in advance
Hello, thank you for a library, I'm actually struggling to find a way to call trpc useSwr hook conditionnaly. Based on the docs, with useSwr, we could do something like:
const { data } = useSWR(shouldFetch ? '/api/data' : null, fetcher)
But I don't see any examples with trpc.useSwr and I have typescript errors than I use the syntax like:trpc.useSWR(shouldFetch ? ['api.data'] : null)
Type 'null' is not assignable to type ... which is expected type error as null is not a part of AppRouter proceduresIs there a way to do it? Am I doing something wrong? Thanks in advance