question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Amplify withAuthenticator React Native createSwitchNavigator Auth.signout() does not return to Sign In page

See original GitHub issue

packages:

    "aws-amplify": "^1.1.6",
    "aws-amplify-react-native": "^2.0.6",
    "expo": "^30.0.1",
    "react": "16.3.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-30.0.0.tar.gz",
    "react-navigation": "^2.16.0",
    "react-redux": "^5.0.7",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0",

My project was created by expo init partyTime with default tab navigators.

withAuthenticator works. However, Auth.signout doesn’t go back to sign in page.

I’ve tried suggestions in here https://github.com/aws-amplify/amplify-js/issues/1529 , but without success.

There is no this.props.onStateChange in the MainScreen component.

How do I pass onStateChange from App.js export default withAuthenticator(App); through <AppNavigators /> and into the Main component?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

15reactions
hszetocommented, Oct 10, 2018

I figured it out. In App.js, add screenProps to AppNavigator component:

<AppNavigator screenProps={{...this.props}} />

screenProps will be passed to the Tab Navigator in the app.

Add a logout button somewhere in the app. On press:

Auth.signOut()
      .then(() => {
         this.props.screenProps.onStateChange('signedOut', null);
      })
      .catch(err => console.log(err));
1reaction
kirkryancommented, Jan 9, 2019

You @hszeto are a legend. Thank you, this has been bugging me for months!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native: AWS Amplify Auth.signOut() not working
If you're using React Native UI from Amplify and wrapped your component with withAuthenticator , below code should work.
Read more >
The Complete React Native Guide to User Authentication with ...
In this tutorial, I will be covering mobile authentication using React Native and AWS Amplify. This guide will cover both React Native and ......
Read more >
The Complete React Native Guide to User Authentication with the ...
This guide will cover both React Native and Expo. ... With Amplify you can incorporate username / password based authentication as well as...
Read more >
A Complete Guide for Integrating AWS Amplify to React Native
The aws-amplify package also comes with a component called Auth that can be used to create custom sign out buttons and use the...
Read more >
使用Amplify框架的完整React Native用户身份验证指南 - 0x资讯
用户名和密码认证; 受保护的路线; 监听认证事件; 基本认证 withAuthenticator HOC. 入门. AWS Amplify为想要使用实际生产就绪用户身份验证 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found