I use Expo SDK 39 for my project. I use expo-google-sign-in
and I do not have any problems with it. It works as a charm. However, I do need a clarification why _syncUserWithStateAsync
is used twice in GoogleSignIn
.
1 on mounting the app:
componentDidMount() {
this.initAsync();
}
initAsync = async () => {
await GoogleSignIn.initAsync({
// You may ommit the clientId when the firebase `googleServicesFile` is configured
clientId: '<YOUR_IOS_CLIENT_ID>',
});
this._syncUserWithStateAsync();
};
Next, on login:
signInAsync = async () => {
try {
await GoogleSignIn.askForPlayServicesAsync();
const { type, user } = await GoogleSignIn.signInAsync();
if (type === 'success') {
this._syncUserWithStateAsync();
}
} catch ({ message }) {
alert('login: Error:' + message);
}
};
The reason I’m asking is because, if this function is invoked twice, means that it will try to sign in to Google twice and setting the state twice.
Any experts here? Do share what you think. Thank you.