Egoist Aoi
Elite
Hello, sino po may alam kung pano makapunta sa homepage ng app after successful sign in using google
Ano ba nalabas paps after login?
heto po, di sya nakakabalik ng home screen
import React, { useState } from "react";
import { useHistory } from "react-router-dom";
import { signInWithGoogle } from "./firebase/auth"; // import your Google sign-in function
function SignInPage() {
const [loading, setLoading] = useState(false);
const history = useHistory(); // get the history object from React Router
const handleSignInWithGoogle = async () => {
setLoading(true);
try {
await signInWithGoogle(); // call your Google sign-in function
setLoading(false);
history.push("/"); // redirect to the homepage
} catch (error) {
setLoading(false);
console.log(error);
}
};
return (
<div>
<button onClick={handleSignInWithGoogle} disabled={loading}>
Sign in with Google
</button>
</div>
);
}
export default SignInPage;