Skip to content

Commit

Permalink
chore(docs): fix Custom Client Session Handling example (#4310)
Browse files Browse the repository at this point in the history
* docs: fix Custom Client Session Handling example

It made reference to a useEffect call that was no longer needed.

* Update docs/docs/getting-started/client.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

Co-authored-by: Lluis Agusti <hi@llu.lu>
  • Loading branch information
reconbot and ubbe-xyz committed Apr 4, 2022
1 parent f91b9dc commit 174f0d6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions docs/docs/getting-started/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,14 @@ export default function App({
}

function Auth({ children }) {
const { data: session, status } = useSession({ required: true })
const isUser = session?.user
// if `{ required: true }` is supplied, `status` can only be "loading" or "authenticated"
const { status } = useSession({ required: true })

if (isUser) {
return children
if (status === 'loading') {
return <div>Loading...</div>
}

// Session is being fetched, or no user.
// If no user, useEffect() will redirect.
return <div>Loading...</div>

return children
}
```

Expand Down

1 comment on commit 174f0d6

@vercel
Copy link

@vercel vercel bot commented on 174f0d6 Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.