I am not able to log out on button click and cannot work out why. I have a logout button on my header.(navigation)
I am new to React.
I have a folder called Store, with Auth-context file, I have a login and logout handler in app.js, I am importing AuthContext from ./store/auth-context.
I have no problems logging in, but I always have to do localStorage.clear() in the console to "logout".
In my Header component, I am calling as const isLoggedIn and onLogout with useContext(AuthContext).
On the bottom of the file in Header.js I have defined
{isLoggedIn && (BasicButton onClick={onLogout}>log out<BasicButton>)}
Since onLogout is storing the logoutHandler, I cannot work out why this will not execute when button is clicked. I am also using React Router version 6.4.4
Auth Context
Handlers