Is there any way to send the below password reset mail by getting user email, const email = event.target.email.value, I have tried but due to the async function, I cannot pass the event parameter? FYI - I am using react hook to send password reset mail. Below code screenshot for your reference.
Finally, I have used here useRef to send reset mail. How can I pass event as a parameter into the async function to send password reset mail?
My code:
const [sendPasswordResetEmail, sending] = useSendPasswordResetEmail(auth);
const handleSubmit = event => {
event.preventDefault();
const email = event.target.email.value;
const password = event.target.password.value;
signInWithEmailAndPassword(email, password)
}
if (loading || sending) {
return <Loading></Loading>
}
let from = location.state?.from?.pathname || "/";
let loginError;
const navigateRegister = () => {
navigate('/register')
}
const resetPassword = async () => {
const email = emailRef.current.value;
await sendPasswordResetEmail(email);
if (email) {
toast('Sent email');
} else {
toast('please enter your email address!!')
}
}
Try using emailRef.current.value to get the email, as seen in resetPassword in your code.