-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSignUp.js
40 lines (36 loc) · 995 Bytes
/
SignUp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SignUp.js
import { useState } from "react";
import { createUserWithEmailAndPassword } from "firebase/auth";
import { auth } from "@/firebase";
const SignUp = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const handleSignUp = async () => {
try {
await createUserWithEmailAndPassword(auth, email, password);
alert("User signed up successfully!");
} catch (error) {
console.error("Error signing up:", error);
alert("Error signing up: " + error.message);
}
};
return (
<div>
<h2>Sign Up</h2>
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="Email"
/>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="Password"
/>
<button onClick={handleSignUp}>Sign Up</button>
</div>
);
};
export default SignUp;