I need to implement in the code below the command for once the user is validated to be redirected to the "Home" screen. The changes I made did not solve my problem. I can create the user, save in Firebase but when I log in I can not direct to the "Home" screen.
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
KeyboardAvoidingView,
StyleSheet,
ImageBackground,
} from 'react-native';
import Login from './screens/Login';
import Register from './screens/Register';
import ForgotPassword from './screens/ForgotPassword';
import { w } from './api/Dimensions';
import Home from './screens/Home';
export default class FirebaseLogin extends Component {
state = {
currentScreen: 'login', // can be: 'login' or 'register' or 'forgot'
};
changeScreen = screenName => () => {
this.setState({ currentScreen: screenName });
};
userSuccessfullyLoggedIn = user => {
this.props.login(user);
};
render() {
let screenToShow;
switch (this.state.currentScreen) {
case 'login':
screenToShow = (
<Login
change={this.changeScreen}
success={this.userSuccessfullyLoggedIn}
/>
);
break;
case 'register':
screenToShow = <Register change={this.changeScreen} />;
break;
case 'forgot':
screenToShow = <ForgotPassword change={this.changeScreen} />;
break;
}
return (
<KeyboardAvoidingView
behavior="position"
keyboardVerticalOffset={-w(40)}
style={styles.container}>
<ImageBackground
source={this.props.background}
style={styles.background}
resizeMode="stretch">
{screenToShow}
</ImageBackground>
</KeyboardAvoidingView>
);
}
}
FirebaseLogin.propTypes = {
login: PropTypes.func.isRequired,
};
FirebaseLogin.defaultProps = {
background: null,
};