Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-vans-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tanstack/react-db": patch
---

Fixed a bug where a race condition could cause initial results not to be rendered when using `useLiveQuery`.
5 changes: 5 additions & 0 deletions packages/react-db/src/useLiveQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ export function useLiveQuery(
versionRef.current += 1
onStoreChange()
})
// Collection may be ready and will not receive initial `subscribeChanges()`
if (collectionRef.current!.status === `ready`) {
versionRef.current += 1
onStoreChange()
}
return () => {
unsubscribe()
}
Expand Down
Loading