Skip to content
Advertisement

I have a problem with my provider to render different navigator stacks

I am implementing a provider which helps me to have the state of my user in different views, the main function of this provider is to render different one or the other stack navigator depending on whether the variable is full or empty, this in order to be able to generate two groups of screens depending on whether the user is authenticated or not. Here my code:

View router.tsx:

JavaScript

Provider user,js:

JavaScript

GeneralStack:

JavaScript

AuthStack:

JavaScript

Login:

JavaScript

Home:

JavaScript

The problem I have is when doing the close session in home, if in login it sends me from the authstack view to generalstack, when I do the close session it doesn’t send me back to login, but it does clean the state of the variable from asyncstorage. Help 🙁

Advertisement

Answer

It looks like you’re not clearing the me variable in your context when the user ends the session. I think your closeSesion method should look like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement