Estoy tratando de mostrar el mensaje de Alerta usando Chakra Ui pero no se muestra. Por favor ayuda.
.catch((error) => { const errorCode = error.code; const errorMessage = error.message; console.log(errorMessage, errorCode); <Alert status='error'> <AlertIcon /> <AlertTitle>Error!</AlertTitle> <AlertDescription>Email/ Password Did Not Matched.</AlertDescription> </Alert> });Los componentes como <Alert /> no se pueden agregar a la captura de una promesa. Debe generar la alerta de forma condicional en la declaración de devolución de un componente de la siguiente manera:
function LoginExample() { const [showAlert, setShowAlert] = useState(false) const handleLogin = (email, password) => { loginUser(email, password) .then((res) => /* handle success */) .catch((error) => { const errorCode = error.code; const errorMessage = error.message; console.log(errorMessage, errorCode); setShowAlert(true) }) } return ( <> {showAlert && ( <Alert status='error'> <AlertIcon /> <AlertTitle>Error!</AlertTitle> <AlertDescription>Email/ Password Did Not Matched.</AlertDescription> </Alert> )} {/* rest of jsx */} </> ) }