Skip to content

Commit ddc1ec6

Browse files
fix(create): address review feedback on Descope add-on
- Gate header avatar on isUserLoading to avoid initial fallback flash - Handle sdk.logout() promise rejection - Fix README to match header-user behavior (no sign-in link) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5b4ecb4 commit ddc1ec6

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

packages/create/src/frameworks/react/add-ons/descope/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
### What's wired up
1414

1515
- **`<AuthProvider>`** at the app root (`src/integrations/descope/provider.tsx`) supplies auth context to the whole tree
16-
- **Header user menu** (`src/integrations/descope/header-user.tsx`) swaps between a "Sign in" link and the signed-in avatar + "Sign out"
16+
- **Header user menu** (`src/integrations/descope/header-user.tsx`) renders the signed-in avatar + "Sign out" button (hidden when signed out)
1717
- **`/demo/descope`** renders the Descope `<Descope flowId="sign-up-or-in" />` flow and a signed-in greeting
1818

1919
### Protecting a route

packages/create/src/frameworks/react/add-ons/descope/assets/src/integrations/descope/header-user.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { useDescope, useSession, useUser } from '@descope/react-sdk'
22

33
export default function HeaderUser() {
44
const { isAuthenticated, isSessionLoading } = useSession()
5-
const { user } = useUser()
5+
const { user, isUserLoading } = useUser()
66
const sdk = useDescope()
77

8-
if (isSessionLoading || !isAuthenticated) return null
8+
if (isSessionLoading || isUserLoading || !isAuthenticated) return null
99

1010
const email = user?.email
1111
const initial = (user?.name || email || 'U').charAt(0).toUpperCase()
@@ -23,7 +23,9 @@ export default function HeaderUser() {
2323
)}
2424
<button
2525
type="button"
26-
onClick={() => sdk.logout()}
26+
onClick={() =>
27+
sdk.logout().catch((err) => console.error('Descope logout error', err))
28+
}
2729
className="rounded-xl px-3 py-1.5 text-sm font-semibold text-[var(--sea-ink-soft)] transition hover:bg-[var(--link-bg-hover)] hover:text-[var(--sea-ink)]"
2830
>
2931
Sign out

0 commit comments

Comments
 (0)