0

I am actually authenticating a firebase connection and want to route to the home page after authentication.

The problem is that whenever I clicked the button it has a wait of 1s almost to receive the resolved state from firebase, and I know that async await resolve after set time out in call stack. So what is the method that should execute it I get resolve state?

This is my approach:

const isActiveStatus =useCallback(() => {
    currentUser !== null ? setIsActive(true) : setIsActive(true) 
    console.log("is Active: "+ isActive)
    isActive ? navigate("/") : console.log("user is not Active")
}, [currentUser])

async function handleSubmit(event) {
    event.preventDefault();
    
    try {
        setError("")
        setLoading(true)
        await signin(emailRef.current.value, passwordRef.current.value)
        isActiveStatus()
        console.log(isActive)
    } catch {
        setError("There is some issue in logging in")
    }
    setLoading(false)
}
Drew Reese
  • 165,259
  • 14
  • 153
  • 181
  • Hello and welcome to stack overflow! Unfortunately, your question is very unclear and it is very hard to tell what you want. Try rephrasing the question and adding more details so people are in a better position to answer. – Hassan Naqvi Sep 22 '22 at 15:03

0 Answers0