I noticed in our app that every time a long-polling request finishes, it causes all associated queries on that collection to return a new data object. In React, this triggers a lot of unnecessary re-renders.
This appears to be because the snapshot version is bumped whenever subscribeChanges is called, even if the list of changes is empty.
|
const subscription = collectionRef.current.subscribeChanges(() => { |
|
// Bump version on any change; getSnapshot will rebuild next time |
|
versionRef.current += 1 |
|
onStoreChange() |
|
}) |
When I patch @tanstack/react-db as below, the problem goes away.

I noticed in our app that every time a long-polling request finishes, it causes all associated queries on that collection to return a new
dataobject. In React, this triggers a lot of unnecessary re-renders.This appears to be because the snapshot version is bumped whenever
subscribeChangesis called, even if the list of changes is empty.db/packages/react-db/src/useLiveQuery.ts
Lines 390 to 394 in 59b406e
When I patch @tanstack/react-db as below, the problem goes away.