'In React Login component Firebase Login signup is working but when I am trying to send a reset password Link then is Not sending to email

In React Login component Firebase login signup is working but when I am trying to send a reset password Link then it is not working. there is no getting email value from the field, but sign-in is working. So unable to send the reset password link in my email.

Login Submit Button : it's working:

 const handleToSubmit = (event) => {
    event.preventDefault();
    const email = event.target.email.value;
    const password = event.target.password.value;
    signInWithEmailAndPassword(email, password)
}

Reset password Function code: it's not working:

<!-- language: lang-js -->

        const resetPassword = async (event) => {
            const email = event.target.email.value
            if (email) {
                await sendPasswordResetEmail(email);
                toast.success(`Check your Email ⮞ ${email}`);
            } else {
                toast.warn('Enter Email  ☹ ');
            }
        }

<!-- end snippet -->

My Email input field: it's working for login but not for reset password

<Form.Group controlId="formBasicEmail">
      <Form.Control type="email" name="email" placeholder="Enter email" />
</Form.Group>

Reset Click Button: it's not working:

    <button onClick={resetPassword}> Reset Password </button>


Solution 1:[1]

I think you are using firebase v9.

So you should pass auth as parameter to the function:

import { getAuth, sendPasswordResetEmail } from  "firebase/auth"; 

const auth = getAuth();
sendPasswordResetEmail(auth, email)
  .then(() => {
    // Password reset email sent!
    // show the toast
  })

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 marc_s