You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
useLiveQuery with localOnlyCollection does not show changes applied during component mount #439
When inserting into a localOnlyCollection inside a useEffect, useLiveQuery does not return the expected data immediately. However, if the insert/delete calls are wrapped in a setTimeout, the query works as expected. This also applies to changes in useLayoutEffect and directly in the component body.
Thanks for the report @doepnern, particularly the repo as thats super helpful.
I've been trying to reproduce it in an isolated test but can't, I think this is an issue that only manifests in a real browser with a "real" browser event loop - React in tests does behave slightly differently. Having said that I also tried to set up a playwright test for it and didn't get that working. I'm keen to get a unit test for this as we need to be sure any change we make isn't reverted in future.
This is fixed by the shared-observer work in #1642. The exact local-only mount-window checks pass for useEffect, useLayoutEffect, and guarded render-body insertion without a timeout. Real-browser timing was not rerun, and mutation during render remains an unsupported React side effect. Closing as completed; please reopen with a current browser reproduction if necessary.
Activity
samwillis commentedon Oct 4, 2025
Thanks for the report @doepnern, particularly the repo as thats super helpful.
I've been trying to reproduce it in an isolated test but can't, I think this is an issue that only manifests in a real browser with a "real" browser event loop - React in tests does behave slightly differently. Having said that I also tried to set up a playwright test for it and didn't get that working. I'm keen to get a unit test for this as we need to be sure any change we make isn't reverted in future.
KyleAMathews commentedon Sep 15, 2026
This is fixed by the shared-observer work in #1642. The exact local-only mount-window checks pass for
useEffect,useLayoutEffect, and guarded render-body insertion without a timeout. Real-browser timing was not rerun, and mutation during render remains an unsupported React side effect. Closing as completed; please reopen with a current browser reproduction if necessary.