Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Before going to other scene how to check loggedIn or not. #2864

Closed
GopiKrishna10 opened this issue Feb 7, 2018 · 3 comments
Closed

Before going to other scene how to check loggedIn or not. #2864

GopiKrishna10 opened this issue Feb 7, 2018 · 3 comments

Comments

@GopiKrishna10
Copy link

Version

"react": "16.2.0",
"react-native": "0.52.0",
"react-native-router-flux": "^4.0.0-beta.28"

Expected behavior

If I log out the app.It should redirect to Login screen which is good and when I hit the back button on Android mobile.It should stay on login screen

Actual behavior

when I click on Logout button it's redirecting to the login screen which is good.if I click the back button on an android mobile.It's taking me to the logout screen.For handling this I used the backHandler.If i hit the back button from login screen on android mobile am closing the app.again click on the app it's redirecting to the LogOut screen.Here is my code.

componentWillMount(){
BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonClick);
}
handleBackButtonClick(){
BackHandler.exitApp()
}

How can I handle this functionality? and how to check before going to another scene is he loggedIn or not.Am not using the REDUX for my app.its, not a big app.

Could you please help me, guys.Am new to react-native

Steps to reproduce

Create an app by using react-native init someName
1.add three basic scenes(login,home,logout)
2.run in android mobile check the flow.

@GopiKrishna10
Copy link
Author

@Blapi and @aksonov Guys could you please help me

@Blapi
Copy link
Collaborator

Blapi commented Feb 10, 2018

I don't really understand your project. Help me please :

You have a home screen, where there is a logout button. You click on this button, so you go from the home screen to the login screen.
What is this logout screen?
What do you really want here? When you launch your app, you want to know if you should either go to the Login Screen (to log you in), or to the Home Screen if you're already logged in? Is that right ?

@GopiKrishna10
Copy link
Author

GopiKrishna10 commented Feb 15, 2018

Sorry @Blapi ,

As of now, I solved the issue by using backhandler in react-native.Thanks for your reply.Just small clarification While navigating to the screens how can check if he is loggedIn or Not.

@Blapi Blapi closed this as completed Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants