This code creates a reset button and a div that holds a text box and a button. When the user clicks the button, the code calls the sendPasswordResetEmail function with the user's email address as the argument. The sendPasswordResetEmail function sends a password reset email to the user.
Library: react
import { auth, sendPasswordResetEmail } from "./firebase";
import { Link } from "react-router-dom";
import { useAuthState } from "react-firebase-hooks/auth";
import "./Reset.css";
import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
function Reset() {
const [email, setEmail] = useState("");
const [user, loading, error] = useAuthState(auth);
const navigate = useNavigate();
useEffect(() => {
if (loading) return;
if (user) navigate("/dashboard");
}, [user, loading]);
return (
<div className="reset">
<div className="reset__container">
<input
type="text"
className="reset__textBox"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="E-mail Address"
/>
<button
className="reset__btn"
onClick={() => sendPasswordResetEmail(email)}
>
Send password reset email
</button>
<div>
Don't have an account? <Link to="/register">Register</Link> now.
</div>
</div>
</div>
);
}
export default Reset;