T
Join ServertRPC
❓-help
data becomes never[] when destructuring with a fallback value
Message Not Public
Sign In & Join Server To View
2 Messages Not Public
Sign In & Join Server To View
10 Messages Not Public
Sign In & Join Server To View
data
property, for example:const { data = [] } = trpc.useQuery(['company.listIds']);
// expecting data to be the inferred type { id: string }[] but instead it's never[]
// This somehow works
const query = trpc.useQuery(['company.listIds']);
const { data = [] } = query;
// data is correctly typed as { id: string }[]
interface Company {
id: string;
}
const { data = [] } = useQuery<Company[]>(['company.listIds'], someFetchFunction);
// data is correctly typed as Company[]
react-query
in @trpc/react
?{ id: string }[] | undefined
react-query
keepPreviousData
doesn't change the type