Skip to content
Advertisement

Can a Firebase error message template or Alert be customised to show custom Alerts?

I am working on a React App. The app has basic auth features. Here is the code below.

JavaScript

The issue here is that i am trying to create a custom alert for a specific error that is “The Email ID Already Exists”. But Firebase has its own predefined error template defined for it.

And when I replace with a custom code mentioned below,

JavaScript

}

it works, but shows the same alert for every error present.

Somone. help. I am relatively new to React and JS.

Advertisement

Answer

Write a custom function that takes in the auth error and displays an Alert accordingly:

JavaScript

This should actually work pretty much out of the box since I am using it in my own code with Firebase just slightly different. I just return a custom string and then display the Alert with it but since you wan’t custom Alerts this is the better way.

Advertisement