How to logout with Auth0 SDK? "You forgot to wrap your component in <Auth0Provider>"
The component you're calling useAuth0
from is outside of the Auth0Provider
, since the Auth0Provider
is its child. You'll need to call useAuth0
from a component that is wrapped in the Provider.
As an example, you could refactor your ToolbarToggleItem
component to take a logoutDestination
as a prop instead of an onClick
function. Then, inside ToolbarToggleItem
, get the logout
function by calling useAuth0
in the body of the function component.
Inside your ToolbarToggleItem
's return, you could have an onPress
that would look like:
onPress={() => logout({ returnTo: logoutDestination })
on the component that handles touch.