Я теряю надежду на решение сетевой ошибки в моем приложении Firebase / React. Ошибка Uncaught Error: Network Error at auth.esm.js:255
иногда появляется в консоли, а иногда просто не отображается, и пользователь успешно входит в систему с помощью Google.
В поисках ответа я не смог найти ничего убедительного (будь то проблемы с переполнением стека или Github). Документация Firebase показывает только Thrown if a network error (such as timeout, interrupted connection or unreachable host) has occurred
об этом.
Ниже мой фрагмент кода для компонента входа в систему.
useEffect(() => {
auth
.getRedirectResult()
.then(function (result) {
if (result.credential) {
const token = result.credential.accessToken
setIdToken(token)
history.push('/')
}
const user = result.user
setUsername(user.displayName)
})
.catch(function (error) {
var errorCode = error.code
var errorMessage = error.message
console.log('errorCode and errorMessage: ', errorCode, errorMessage)
})
}, [])
function handleSignInWithGoogle() {
signInWithGoogle()
setLoading(true)
}
//then, inside of my return statement
<button onClick={() => handleSignInWithGoogle()}> Sign in with Google </button>
И это то, что находится внутри моего файла Firebase
firebase.initializeApp(firebaseConfig)
export const firestore = firebase.firestore()
export const auth = firebase.auth()
export const provider = new firebase.auth.GoogleAuthProvider()
export const signInWithGoogle = () => auth.signInWithRedirect(provider)