Mamunur Rashid
Mamunur Rashid

Reputation: 1185

showing console warning or error into the scrren

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.

Link of Login Components

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?

console errors

Upvotes: 1

Views: 79

Answers (1)

inchw0rm
inchw0rm

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

Related Questions