Skip to content

Commit 11aac86

Browse files
committed
docs(upgrade-guide): correct the non-suspense behavior, and restore useUser coverage
Both from Armando's review. The guide said the components "only ever worked with suspense={true}, and in non-suspense mode they logged a deprecation warning and rendered anyway". Wrong in both halves, and wrong in opposite directions. Rendered each shape against v5: - Plain AuthCheck worked in non-suspense mode, warning aside. - AuthCheck with requiredClaims warned, then threw. - ClaimsCheck alone threw before reaching its warning, so those users may have seen no warning at all. The person most exposed is the one running plain AuthCheck without suspense. Their app works today, the old text told them it never did, so they would skip the entry and hit a load-time break. The SigninGate stand-in now uses useUser rather than useSigninCheck, so the tests inside describe('useUser') cover useUser again. Verified both ways: with the gate on useSigninCheck, making useUser throw left the navigating-away test passing while the same mutation failed it on v5. With the gate on useUser it fails again. Suite is 12/12, both typechecks clean. Also from the review: the migration sample guarded loading and then read signInCheckResult.signedIn, which throws a TypeError when the observable errors before its first emission, since ObservableStatus declares data: T rather than a discriminated union. It now destructures error and checks status === 'error'.
1 parent fc8d838 commit 11aac86

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

‎docs/upgrade-guide.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ReactFire v5 contains breaking changes. This section lists them as they land; ad
66

77
Both components were deprecated in v4 (May 2021) in favor of the `useSigninCheck` hook, which shipped in the same release. They have been removed in v5.
88

9-
They only ever worked with `<FirebaseAppProvider suspense={true}>`, and in non-suspense mode they logged a deprecation warning and rendered anyway. If you used them without suspense, you have been seeing that warning.
9+
`ClaimsCheck`, and `AuthCheck` with `requiredClaims`, only ever worked with `<FirebaseAppProvider suspense={true}>`. In non-suspense mode they threw `Error: ClaimsCheck must be run in Suspense mode` as soon as a signed-in user reached the claims check. `AuthCheck` without `requiredClaims` did work in non-suspense mode. Both `AuthCheck` shapes logged a deprecation warning first, but `ClaimsCheck` on its own threw before reaching its warning, so you may have seen no warning at all.
1010

1111
**If you use either component**, replace it with `useSigninCheck`:
1212

@@ -17,9 +17,10 @@ They only ever worked with `<FirebaseAppProvider suspense={true}>`, and in non-s
1717
</AuthCheck>
1818

1919
// After
20-
const { status, data: signInCheckResult } = useSigninCheck({ requiredClaims: { admin: true } });
20+
const { status, data: signInCheckResult, error } = useSigninCheck({ requiredClaims: { admin: true } });
2121

2222
if (status === 'loading') return <LoadingSpinner />;
23+
if (status === 'error') return <ErrorPage error={error} />;
2324

2425
return signInCheckResult.signedIn && signInCheckResult.hasRequiredClaims ? <AdminPage /> : <SignInForm />;
2526
```

‎test/auth.test.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ describe('Authentication', () => {
2929
);
3030

3131
// Stands in for the removed <AuthCheck>: renders children when signed in and a fallback
32-
// when not. Kept in suspense mode behind a Suspense boundary so the tests that used
33-
// AuthCheckWrapper still exercise the same path.
32+
// when not. Built on useUser, which is what AuthCheck itself used before delegating to
33+
// ClaimsCheck, so the tests in describe('useUser') keep exercising useUser. These tests
34+
// never passed requiredClaims, so the claims path is not part of what they covered.
3435
const SigninGate = ({ children }: { children?: any }) => {
35-
const { data: signinResult } = useSigninCheck();
36+
const { data: user } = useUser();
3637

37-
if (signinResult?.signedIn !== true) {
38+
if (!user) {
3839
return <h1 data-testid="signed-out">not signed in</h1>;
3940
}
4041

0 commit comments

Comments
 (0)