Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anghelalexandra/4fd7f61f9851ffee69584d7128b72e32 to your computer and use it in GitHub Desktop.
Save anghelalexandra/4fd7f61f9851ffee69584d7128b72e32 to your computer and use it in GitHub Desktop.
iOS and Android apps with React Native - Switching between screens with React Native Navigation
import React from 'react';
import PropTypes from 'prop-types';
class LoginScreen extends React.Component {
// ...
componentWillReceiveProps(newProps) {
if (newProps.authenticated === true) {
this.handleSuccessfulLogin();
}
}
handleSuccessfulLogin() {
this.props.navigator.resetTo({
screen: 'MyApp.Dashboard',
backButtonHidden: true,
animated: true,
animationType: 'fade',
});
}
render() {
// ..
}
}
LoginScreen.propTypes = {
authenticated: PropTypes.bool.isRequired,
navigator: PropTypes.shape({
resetTo: PropTypes.func.isRequired,
}).isRequired,
};
export default LoginScreen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment