'Change navbar when logged in MySQL react
I have a mysql node login on my site and am trying to get the header to change immediately when the user logs in. Right now it only runs the user check function when the page loads so you have to refresh to get the right header. How can I get this to run when the user logs in or logs out?
useEffect(() => {
fetch('http://localhost:81/isUser')
.then(response => response.json())
.then(data => {setIsUser(data)});
}, [])
<AuthorizationContext.Provider value={user}>
{isUser ? <NavbarLogged logout={logout} connect={getBalance} /> : <Navbar handleShow={handleShow} handleShowSignup={handleShowSignup}/>}
</AuthorizationContext.Provider>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
