react-google-login#useGoogleLogin JavaScript Examples

The following examples show how to use react-google-login#useGoogleLogin. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginHooks.js    From react-google-authentication with MIT License 6 votes vote down vote up
function LoginHooks() {
  const onSuccess = (res) => {
    console.log('Login Success: currentUser:', res.profileObj);
      `Logged in successfully welcome ${} ?. \n See console for full profile object.`

  const onFailure = (res) => {
    console.log('Login failed: res:', res);
      `Failed to login. ? Please ping this to repo owner`

  const { signIn } = useGoogleLogin({
    isSignedIn: true,
    accessType: 'offline',
    // responseType: 'code',
    // prompt: 'consent',

  return (
    <button onClick={signIn} className="button">
      <img src="icons/google.svg" alt="google login" className="icon"></img>

      <span className="buttonText">Sign in with Google</span>