Skip to content

Commit

Permalink
fix(client): set useSession loading state correctly (#1468)
Browse files Browse the repository at this point in the history
This is fixing #1467.

The issue was due to doing the `setLoading(false)` in the finally:  as we can do an early return [here](https://github.com/nextauthjs/next-auth/blob/a7e08e2a3266efa9c82eb859e7141c798fcf07ae/src/client/index.js#L100-L100), we would still go to the finally and mark the session as being loaded.

I simply removed the `finally` block to only set the `loading` state to false when:
- the data is ready
- an error occures
  • Loading branch information
ValentinH authored Mar 7, 2021
1 parent ba7aed1 commit e553573
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ function _useSessionHook (session) {
__NEXTAUTH._clientSession = newClientSessionData

setData(newClientSessionData)
setLoading(false)
} catch (error) {
logger.error('CLIENT_USE_SESSION_ERROR', error)
} finally {
setLoading(false)
}
}
Expand Down

1 comment on commit e553573

@vercel
Copy link

@vercel vercel bot commented on e553573 Mar 7, 2021

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.