Skip to content
Source
Docs
Explore
Skills
MCP servers
For agents
Search or jump to…
Sign in
Sign up
TanStack
/
query
Pull requests
TanStack
query
Public
Synced with GitHub
Popular #7
Fork
0
0
0
0
1
2
3
4
5
6
7
8
9
Code
Architecture
Issues
Pull requests
Community
Assets
CI
Agents
Settings
fix(query-core): update initialData when an observer mounts while a Query without data exists
#9620
Send to my agent
Merged
TkDodo
merged 1 commit into
main
from
refs/pull/9620/head
·
merged by
TkDodo
last year
View on GitHub
Conversation
6
Commits
1
Files changed
2
Impact
Showing
2 changed files
with
74 additions
and
0 deletions
.
x
0 of 2 viewed, 2 left
Files
Hide whitespace
Unified
Split
62 additions and 0 deletions
+62
-0
packages/query-core/src/__tests__/query.test.tsx
Modified
Diff
Before/After
Viewed
packages/query-core/src/__tests__/query.test.tsx
View file
Expand up
Show all 1,192 lines
@@ -1193,6 +1193,68 @@
1193
1193
expect
(query.
state
.
data
).
toBe
(
'initial data'
)
1194
1194
})
1195
1195
1196
+
test
(
'should update initialData when Query exists without data'
,
async
() => {
1197
+
const
key =
queryKey
()
1198
+
const
queryFn = vi.
fn
(
async
() => {
1199
+
await
sleep
(
100
)
1200
+
return
'data'
1201
+
})
1202
+
1203
+
const
promise = queryClient.
prefetchQuery
({
1204
+
queryKey
: key,
1205
+
queryFn,
1206
+
staleTime
:
1000
,
1207
+
})
1208
+
1209
+
vi.
advanceTimersByTime
(
50
)
1210
+
1211
+
expect
(queryClient.
getQueryState
(key)).
toMatchObject
({
1212
+
data
:
undefined
,
1213
+
status
:
'pending'
,
1214
+
fetchStatus
:
'fetching'
,
1215
+
})
1216
+
1217
+
const
observer =
new
QueryObserver
(queryClient, {
Home
Search
Explore
Menu