My attempts to debug the issue have been unsuccessful, resulting in my code not identifying errors like creating a user with an email that is already registered. While it does provide a response, it's not the one I anticipated such as firebase/email-in-use. The console displays an error with undefined. Here is the snippet of code:
import { createUserWithEmailAndPassword } from "firebase/auth"
import { auth } from "../../../firebase/config"
export default function Content() {
const emailSignIn = async () =>{
try{
createUserWithEmailAndPassword(auth, email, password)
}catch(error){
console.log(error)
}
}
return (
<div className="h-[5vh]">
<input type="text" placeholder="Email address" onChange={(e)=> setEmail(e.target.value)} className="w-full border-2 h-[4vh] border-[#e4ebe4] rounded-2xl font-normal text-base p-3 pl-5"/>
</div>
<div className="h-[5vh]">
<input type="text"
placeholder="Password (8 or more characters)" onChange={(e)=> setPassword(e.target.value)} className="w- full border-2 h-[4vh] border-[#e4ebe4] rounded-2xl font-normal text-base p-3 pl-5"/>
</div>
The console error message reads:-
app-index.js:31 undefined
window.console.error @ app-index.js:31
console.error @ hydration-error-info.js:45
emailSignIn @ content.js:24
callCallback @ react-dom.development.js:19443
invokeGuardedCallbackImpl @ react-dom.development.js:19492
invokeGuardedCallback @ react-dom.development.js:19567
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:19581
executeDispatch @ react-dom.development.js:30621
processDispatchQueueItemsInOrder @ react-dom.development.js:30653
processDispatchQueue @ react-dom.development.js:30666
dispatchEventsForPlugins @ react-dom.development.js:30677
eval @ react-dom.development.js:30867
batchedUpdates$1 @ react-dom.development.js:23747
batchedUpdates @ react-dom.development.js:27583
dispatchEventForPluginEventSystem @ react-dom.development.js:30866
dispatchEvent @ react-dom.development.js:28639
dispatchDiscreteEvent @ react-dom.development.js:28610
I have attempted to access the error.code
and error.message
properties without success. Additionally, I tried utilizing firebase functions to check if a user with the email already exists but encountered difficulties with the .then structure and async function behavior in JavaScript. This project is developed using next.js version 13.