doc: add useHistory and auth with userEmailand Password
This commit is contained in:
+11
-1
@@ -1,10 +1,12 @@
|
||||
import React, { useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Link, useHistory } from "react-router-dom";
|
||||
import { auth } from "./firebaseInit";
|
||||
import "./Login.css";
|
||||
|
||||
function Login() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const history = useHistory();
|
||||
|
||||
const signIn = (e) => {
|
||||
e.preventDefault();
|
||||
@@ -12,6 +14,14 @@ function Login() {
|
||||
|
||||
const register = (e) => {
|
||||
e.preventDefault();
|
||||
auth
|
||||
.createUserWithEmailAndPassword(email, password)
|
||||
.then((auth) => {
|
||||
if (auth) {
|
||||
history.push("/");
|
||||
}
|
||||
})
|
||||
.catch((error) => alert(error.message));
|
||||
};
|
||||
return (
|
||||
<section className="login">
|
||||
|
||||
Reference in New Issue
Block a user