-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correctly block unauthed users from pages that require auth
previously, a page that required authorization would show the spinning modal indefinitely, instead of showing the message that informs the user they must be signed in. this is because the variable that determined whether the spinner should show, always remained true. this commit breaks out the logic to first check if there is a user. what renders on the page is based on that. checking for the presence of a session has to come after all of the hooks so we don't violate the react-hooks/rules-of-hooks rule. ref: https://legacy.reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level we return the loading state in two different locations because it's rendered based on separate conditions. when isLoading is true because we don't have a user, it doesn't ever become false. that's why we were previously returning the loading spinner indefinitely. using a guard clause with an early return inside the api methods also violates the react-hooks/rules-of-hooks rule.
- Loading branch information
Showing
3 changed files
with
87 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters