From ea64819d91a792d76fa7a89a696fcf223f242ed7 Mon Sep 17 00:00:00 2001 From: "Rayyan (Rayy)" Date: Tue, 12 Sep 2023 09:28:56 +0000 Subject: [PATCH] Linking Firebase Databse with Signup --- src/App.js | 53 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/App.js b/src/App.js index d5e93cd..5129f95 100644 --- a/src/App.js +++ b/src/App.js @@ -14,6 +14,7 @@ import { Signup } from "./pages/Signup" function App() { const FBapp = initializeApp(FirebaseConfig) + const FBauth = getAuth(FBapp) // navigation array const navItems = [ { label: "Home", link: "/" }, @@ -22,31 +23,41 @@ function App() { { label: "Create Account", link: "/signup" }, { label: "Log in", link: "/signin" }, ] -// navigation for authenticated user -const AuthnavItems = [ + // navigation for authenticated user + const AuthnavItems = [ { label: "Home", link: "/" }, { label: "About", link: "/about" }, { label: "Contact", link: "/contact" }, - { label: "Log out", link: "/signout"} -] + { label: "Log out", link: "/signout" } + ] -/// application states -const [nav, setNav ] = useState( navItems ) + /// application states + const [nav, setNav] = useState(navItems) - const saySomething = ( word ) => { - alert( word ) + const saySomething = (word) => { + alert(word) } - return ( -
-
- - } /> - } /> - } /> - } /> - -
- ); -} -export default App; \ No newline at end of file + + // signing up a user + const signUp = (email, password) => { + createUserWithEmailAndPassword(FBauth, email, password) + .then((userCredential) => { + // do something + }) + .catch((error) => console.log(error.message)) + } + return ( +
+
+ + } /> + } /> + } /> + } /> + +
+ ); + } + + export default App; \ No newline at end of file