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.
