Reputation: 1185
I am using React Native, firebase. I have a login component that has an email and password field. It is validated using formik and yup. Here is my code link using expo snack.
It is working properly if correct credentials are provided. However, if I provided the wrong password, any warning is not showing, however, in the console, there is an error message. How can I show those error messages on the screen or below the password field?
Upvotes: 1
Views: 79
Reputation: 111
I'd suggest the following approach:
First of all, we want to have a
import React, {useState} from 'react'
on the top of your component add
[loginErrorMessage, setErrorMessage] = useState('')
now in the return of your function component you want to add a text field like this
<Text>{loginErrorMessage}</Text>
at last in your catch statement of the handleSignup function add
setErrorMessage(error.message)
Upvotes: 1