justjohnd / wayou-kitchen

wayou-kitchen.vercel.app
0 stars 0 forks source link

Change navbar link text if session has expired #31

Closed justjohnd closed 2 years ago

justjohnd commented 2 years ago

If the user's token has expired but the authToken still resides in localstorage, the next attempt to access /private will redirect to /login.

However, will read that there is an authToken, and show "logout", whereas, it should say "Register / Sign In".

Solution: Create a stateful variable that will tell whether the session is expired and make the login/logout link text contingent upon that variable.

Question: Why doesn't Navbar rerender? Because Navbar is a sibling of /login or /parent, so will not rerender just because the siblings rerender.