Skip to content
Open
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: 4 additions & 1 deletion packages/react-db/src/useLiveQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const DEFAULT_GC_TIME_MS = 1 // Live queries created by useLiveQuery are cleaned

export type UseLiveQueryStatus = CollectionStatus | `disabled`

const serverSnapshot = { collection: null, version: 0 }

/**
* Create a live query using a query function
* @param queryFn - Query function that defines what data to fetch
Expand Down Expand Up @@ -467,7 +469,8 @@ export function useLiveQuery(
// Use useSyncExternalStore to subscribe to collection changes
const snapshot = useSyncExternalStore(
subscribeRef.current,
getSnapshotRef.current
getSnapshotRef.current,
() => serverSnapshot
)

// Track last snapshot (from useSyncExternalStore) and the returned value separately
Expand Down
Loading