Adding Google and Anonymous Auth
Before you begin :
Adding Anonymous Auth
import * as React from "react";
import { render } from "react-dom";
import {
FirebaseAuthProvider,
FirebaseAuthConsumer
} from "@react-firebase/auth";
import firebase from "firebase/app";
import { config } from "./test-credentials";
const IDontCareAboutFirebaseAuth = () => {
return <div>This part won't react to firebase auth changes</div>;
};
const App = () => {
return (
<div>
<IDontCareAboutFirebaseAuth />
<FirebaseAuthProvider {...config} firebase={firebase}>
<div>
Hello <div>From Auth Provider Child 1</div>
<FirebaseAuthConsumer>
{({ isSignedIn, firebase }) => {
if (isSignedIn === true) {
return (
<div>
<h2>You're signed in 🎉 </h2>
<button
onClick={() => {
firebase
.app()
.auth()
.signOut();
}}
>
Sign out
</button>
</div>
);
} else {
return (
<div>
<h2>You're not signed in </h2>
<button
onClick={() => {
firebase
.app()
.auth()
.signInAnonymously();
}}
>
Sign in anonymously
</button>
</div>
);
}
}}
</FirebaseAuthConsumer>
</div>
<div>Another div</div>
</FirebaseAuthProvider>
</div>
);
};
render(<App />, document.getElementById("root"));

Cleaning up before we continue
Adding Google Auth

Adding a loading indicator

Handling Errors

Last updated