-
Notifications
You must be signed in to change notification settings - Fork 156
feat(implement github login): React component + Hook for GitHub OAuth #397
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
base: master
Are you sure you want to change the base?
Conversation
|
|
@Migggz is attempting to deploy a commit to the momensherif's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@MomenSherif The only thing left is updating the root README.md to reflect that we now have two packages: one for Google and one for GitHub. We can add a few simple usage snippets for each, along with links to their individual READMEs so users can check the full documentation. I’ll leave this part to you if you want, or I can handle it myself, whatever works for you 😄 |
|
I would love if you can do it 🙌🏻، Have separate README for each package guide inside the package. And the root README, shows the two packages and links for each doc |
| setIsLoading(false); | ||
| onError(error instanceof Error ? error : new Error(String(error))); | ||
| } | ||
| }, [options, state, isLoading]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memoization here will not work, as options most probably users will pass at as plain object, and it will be with new reference every time.
the object here will be with new reference each time
const { initiateGitHubLogin, isLoading } = useGitHubLogin({
clientId: 'xxxxx',
redirectUri: 'http://localhost:3000/callback',
onSuccess: response => {
console.log('Success:', response);
},
onError: error => {
console.error('Error:', error);
},
});we will need to explicitly have each option in the deps array, and for callbacks as we don't want the user of the hook to use useCallback to memoize the onSuccess, onError and onRequest
we can have them like this, similar what we do in useGoogleLogin hook
const onSuccessRef = useRef(onSuccess);
onSuccessRef.current = onSuccess;or have this custom hook https://gist.github.com/MomenSherif/d6193f21e0c0c496fde7ab9ba7d0755a, will help us avoid rerender because of inline methods as parameters
|
@Migggz Thank you for the effort ❤️, really appreciated. left 2 small comments, we can proceed with them. and will release it after that |
…th authentication
…cements - Removed GithubLoginButton - Simplified Building Github OAuth URL using URLSearchParams - Simplified OAuthError Builder and its states - Refactor PopupWindow and Simplified the code - Updated README accordingly BREAKING CHANGE: Removed the GithubLoginButton
…ed PopupWindowOptions type
…seGitHubLogin options handling - Adjusted PopupWindow dimensions for better user experience. - Refactored useGitHubLogin to extract individual options and utilize refs for callbacks.
ff1fd06 to
92546b5
Compare
|
@MomenSherif Nice catch 😄 |
No description provided.