Commit ebc87af
fix: seed useUser with auth.currentUser to prevent undefined on initial render (#731)
* fix: seed useUser with auth.currentUser on initial render
Restores synchronous user access that was removed in 4.2.3 (#539).
Without it, child components calling useUser() see status:'loading' /
data:undefined on first render even when the user is already signed in,
because a fresh SuspenseSubject has to wait for the async
onAuthStateChanged callback before emitting.
Only seeds initialData when auth.currentUser is truthy, so the
uninitialized-auth case (currentUser is null before SDK reads from
storage) is not incorrectly treated as signed-out.
Fixes #582
* Update src/auth.tsx
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* docs: regenerate API reference after useUser line number shift
* docs: regenerate API reference with correct upstream repo source links
* test: add regression test for useUser first-render in useSigninCheck guard
* test: replace guard-pattern test with NEVER-observable regression test
The guard-pattern test passed on main because SuspenseSubject's warmup
subscription made onAuthStateChanged fire before getSnapshot() was called.
The new test installs NEVER as the auth:user observable so it can never emit,
isolating the synchronous-user guarantee to the initialData seeding path only.
Fails on main (status:'loading'), passes with the fix (status:'success').
* fix: return new object from initialData path instead of mutating shared snapshot
useObservable was mutating the object returned by getSnapshot() in-place.
That object is SuspenseSubject._immutableStatus, a single shared reference
across all components using the same observableId. One component's initialData
render would corrupt the snapshot for all other components.
Fixes #736
---------
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent 9865aeb commit ebc87af
15 files changed
Lines changed: 88 additions & 30 deletions
File tree
- docs/reference
- functions
- interfaces
- type-aliases
- src
- test
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments