Skip to content
Source
Sign inSign up
TanStack/query

`data` inside `combine` is undefined when using `useSuspenseQueries` #7197

Send to my agent
ClosedNMinhNguyen(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

The types for data when using useSuspenseQueries with combine say that it’s not undefined, but it appears that combine is called when individual queries still have isLoading: true (i.e. before the component unsuspends). I’m not sure if this is a typing bug, or whether combine shouldn’t be called until data is populated (this seems more reasonable to me).

Your minimal, reproducible example

https://codesandbox.io/p/devbox/elegant-wozniak-tgds5q?file=%2Fsrc%2Findex.tsx

Steps to reproduce

  1. Open repro link
  2. Notice an error right away: Cannot read properties of undefined (reading 'value')

Expected behavior

Either a TypeScript error or no runtime error.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 123.0

Tanstack Query adapter

react-query

TanStack Query version

5.28.9

TypeScript version

5.4.3

Additional context

No response

  1. I'm pretty sure combine shouldn't run until the queries finish suspending. Will take a look

  2. TkDodo added labelsbug

  3. TkDodo added labelssuspense

  4. TkDodo added labelspackage: react-query

  5. TkDodo closed this

Sign in to join this conversation.