Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
How to display auth errors with p tag

how to display to user an auth error differently than with alert? For example: User will type a bad password, and a p tag will tell him, that he typed uncorrect password. Using Firebase v9 and React.

Some code:

    import React from 'react'
import { Link, useNavigate } from "react-router-dom";
import { UserAuth } from '../context/AuthContext';
import { useState } from 'react';



const Signin = () => {
  const [email, setEmail] = useState('')
  const [password, setPassword] = useState('')
  const [error, setError] = useState('');
  const navigate = useNavigate();

  const { signIn } = UserAuth();

  const handleSubmit = async (e) => {
    e.preventDefault();
    setError('')
    try{
        await signIn(email, password)
        navigate("/");
    } catch (e) {
      setError(e.message)
      alert(e.message)
      
    }
  }

  return (
    <div className='Signin'>Signin
    
    <form onSubmit={handleSubmit}>
         
            <label>Email</label>
            <input onChange={(e) => setEmail(e.target.value)} type="email"/>
            <label>password</label>
            <input onChange={(e) => setPassword(e.target.value)} type="password"/>
            <button type="submit">Sign up</button>
            <p className='errorp'></p>
            
        </form>
    
    </div>
  )
}

export default Signin

Thank you!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Something like {error && <p className='errorp'>{error}</p>}

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!