Created with react-native init
- Clone repo
- install modules with
yarn install
ornpm install
cd ios
and thenpod install
- run on your device/simulator (docs)
Example repo for an issue within the AWS Amplify library, specifically aws-amplify-react-native
where using the drop-in withAuthenticator
HOC and a custom Sign Out button that calls Auth.signOut()
fails to change the Authenticators authState
causing the User to appear as if they are still signed in.
Reported issue found here
The video shows Signing in using the withAuthenticator
HOC and Signing out with a custom button and Auth.signOut()
.
After clicking the Logout button the User still sees the screens as if they are signed in.
On an app reload, it is detected that the User has been logged out finally.
- (BEST IMO) onHubCapsule in the Authenticator listens especially for the
signOut
payload to set theauthState
onHubCapsule(capsule) {
const {channel, payload, source} = capsule;
if (channel === 'auth') {
// calling Auth.signOut() automatically dispatches Hub payload to Auth channel with signOut event
if (payload.event === 'signOut') {
// due this to circumvent isMounted checks in checkUser() as signOut is a case we want Authenticator
// to take over even though it isnt mounted
this.setState({authState: 'signIn', authData: null, error: null});
if (this.props.onStateChange) {
this.props.onStateChange('signIn', null);
}
}
} else {
this.checkUser(payload);
}
}
- allow developers to
Hub.dispatch()
and directly set theauthState
if needed