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
Problem
If this code is invoked right on page load, it often does nothing:
The issue happens because callbacks are internally waiting for the Google script to finish loading and
scriptLoadedSuccessfullyto betrue. 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:
login()was invoked before it loadedonErrorwith a reason to indicate that the script is not loaded, then users would have a way to handle it in their applications