Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix useAuthProvider may return undefined when no authProvider is available #9861

Merged
merged 2 commits into from
May 21, 2024

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented May 21, 2024

Fixes BC introduced by #9760 (comment)

Copy link
Member

@fzaninotto fzaninotto left a comment

Choose a reason for hiding this comment

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

A couple nitpicks, but apart from that, 👍

},
[resetStore, location, navigate, loginUrl, queryClient]
[authProvider, resetStore, loginUrl, queryClient, location, navigate]
Copy link
Member

Choose a reason for hiding this comment

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

This is problematic: location changes on every navigation, so the callback memoization is weak. You're using a locationRef for the sarch and hash, why not for the pathName?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why it was not done for pathName (I just moved the content of the second useCallback). But I assume we probably simply forgot to change this second callback to use refs while we changed the first callback, 2 years ago. Besides I can't think of any negative consequences this might have, so I used refs in this second part, too.
Nice catch!

timer = setTimeout(() => {
timer = undefined;
}, 0);
? authProvider
Copy link
Member

Choose a reason for hiding this comment

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

I think this method is a bit too long for a legible ternary. I'd prefer a leave early.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@adguernier adguernier self-requested a review May 21, 2024 12:44
@fzaninotto fzaninotto merged commit 63536b4 into next May 21, 2024
14 checks passed
@fzaninotto fzaninotto deleted the fix-authProviderContext-type branch May 21, 2024 13:34
@fzaninotto fzaninotto added this to the 5.0.0 milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review v5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants