discord-questions.trpc.io/m/1030047679977357312

Preview meta tags from the discord-questions.trpc.io website.

Linked Hostnames

7

Thumbnail

Search Engine Appearance

Google

https://discord-questions.trpc.io/m/1030047679977357312

data becomes never[] when destructuring with a fallback value - tRPC

Currently it doesn't seem possible to set a fallback value on a destructured `data` property, for example: ```ts 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 }[] ``` The "equivalent" with pure react-query: ```ts interface Company { id: string; } const { data = [] } = useQuery<Company[]>(['company.listIds'], someFetchFunction); // data is correctly typed as Company[] ``` Does anyone know if there's a way to achieve the same behaviour of `react-query` in `@trpc/react`?



Bing

data becomes never[] when destructuring with a fallback value - tRPC

https://discord-questions.trpc.io/m/1030047679977357312

Currently it doesn't seem possible to set a fallback value on a destructured `data` property, for example: ```ts 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 }[] ``` The "equivalent" with pure react-query: ```ts interface Company { id: string; } const { data = [] } = useQuery<Company[]>(['company.listIds'], someFetchFunction); // data is correctly typed as Company[] ``` Does anyone know if there's a way to achieve the same behaviour of `react-query` in `@trpc/react`?



DuckDuckGo

https://discord-questions.trpc.io/m/1030047679977357312

data becomes never[] when destructuring with a fallback value - tRPC

Currently it doesn't seem possible to set a fallback value on a destructured `data` property, for example: ```ts 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 }[] ``` The "equivalent" with pure react-query: ```ts interface Company { id: string; } const { data = [] } = useQuery<Company[]>(['company.listIds'], someFetchFunction); // data is correctly typed as Company[] ``` Does anyone know if there's a way to achieve the same behaviour of `react-query` in `@trpc/react`?

  • General Meta Tags

    6
    • title
      data becomes never[] when destructuring with a fallback value - tRPC
    • charset
      utf-8
    • viewport
      width=device-width, initial-scale=1
    • next-size-adjust
    • description
      Currently it doesn't seem possible to set a fallback value on a destructured `data` property, for example: ```ts 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 }[] ``` The "equivalent" with pure react-query: ```ts interface Company { id: string; } const { data = [] } = useQuery<Company[]>(['company.listIds'], someFetchFunction); // data is correctly typed as Company[] ``` Does anyone know if there's a way to achieve the same behaviour of `react-query` in `@trpc/react`?
  • Open Graph Meta Tags

    3
    • og:title
      data becomes never[] when destructuring with a fallback value - tRPC
    • og:description
      Currently it doesn't seem possible to set a fallback value on a destructured `data` property, for example: ```ts 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 }[] ``` The "equivalent" with pure react-query: ```ts interface Company { id: string; } const { data = [] } = useQuery<Company[]>(['company.listIds'], someFetchFunction); // data is correctly typed as Company[] ``` Does anyone know if there's a way to achieve the same behaviour of `react-query` in `@trpc/react`?
    • og:image
      https://discord-questions.trpc.io/og/post?id=1030047679977357312
  • Twitter Meta Tags

    4
    • twitter:card
      summary_large_image
    • twitter:title
      data becomes never[] when destructuring with a fallback value - tRPC
    • twitter:description
      Currently it doesn't seem possible to set a fallback value on a destructured `data` property, for example: ```ts 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 }[] ``` The "equivalent" with pure react-query: ```ts interface Company { id: string; } const { data = [] } = useQuery<Company[]>(['company.listIds'], someFetchFunction); // data is correctly typed as Company[] ``` Does anyone know if there's a way to achieve the same behaviour of `react-query` in `@trpc/react`?
    • twitter:image
      https://discord-questions.trpc.io/og/post?id=1030047679977357312
  • Link Tags

    12
    • canonical
      https://discord-questions.trpc.io/m/1030047679977357312
    • icon
      https://cdn.answeroverflow.com/867764511159091230/6af104c7f0f39a12fcd55bd7bd28928f/icon.png
    • preload
      https://www.answeroverflow.com/_next/static/media/4f05ba3a6752a328-s.p.woff2
    • preload
      https://www.answeroverflow.com/_next/static/media/9cf9c6e84ed13b5e-s.p.woff2
    • preload
      /discord/4.png

Links

12