Skip to content

useGoogleLogin silently does nothing if invoked too soon #391

@ArmorDarks

Description

@ArmorDarks

Problem

If this code is invoked right on page load, it often does nothing:

const login = useGoogleLogin(...)

login()

The issue happens because callbacks are internally waiting for the Google script to finish loading and scriptLoadedSuccessfully to be true. See here.

However, if Google script took too long to load due to a bad network, or loading failed completely, invoking it will just do nothing, and there will be no errors or any indication in the console.

Proposal

Options:

  • Ensure that script is always awaited even if login() was invoked before it loaded
  • Emit onError with a reason to indicate that the script is not loaded, then users would have a way to handle it in their applications

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions