Feature: I want to automatically sign in with the user's profile if he or she successfully signed-in the previous web session.
Problem: I'm getting "No Firebase App" error in my React project while trying to execute firebase.auth(). The main firebase object initialization is triggered at the end of my index.js file with firebase.initializeApp(firebaseConfig). From what I can gather the firebase instance isn't properly initialized while executing authentication portion of code. Nomrally I would expect to perform the auth on the callback from the init function but there's none. So my question is what would be the best place to do the aforementioned automatic authentication/signing-in during the webpage load? Currently the authentication is performed on componentDidMount which obviously doesn't do the trick...
componentDidMount = () => {
if (localStorage.getItem("auth") == "google")
this.authenticate();
};
authenticate = () => {
var provider = new firebase.auth.GoogleAuthProvider();
firebase // <- exception
.auth()
.signInWithPopup(provider)
.then(function (result) {
// @ts-ignore
var token = result.credential.accessToken;
user = result.user;
localStorage.setItem("auth", "google");
firebase.initializeApp(firebaseConfig)at the beginning ofindex.js, before the component instead of the end ? - kunquanReactDOM.renderportion of code) with the following error: Unhandled Rejection (TransactionInactiveError): A request was placed against a transaction which is currently not active, or which is finished - Eric