I was trying to use useContext to change the authentication state when a user logs in and this would be received in other components to conditionally show based on whether the user has logged in.
Login Context was setup as below
I passed the provider in this way
I made a button which upon clicking sets loggedIn
as true
However, when I re-route to store
, the value from useContext
still stays as false
although I have updated it in the Login
component
Upon routing back to "/login" the state from useContext
still shows false
rather than true
Am I missing something wrt how useContext
works?