Move from one window to another in react native and firebase

0

My question is how to pass if my form is true with an if this is my code

firebase.auth().onAuthStateChanged((user) => {
if (user != null) {
console.log(user)
}
})
}

signUpUser = (email, password) => {
try {
 if (this.state.password.length < 6) {
 alert("Please enter atleast 6 characters")
 return;
}
firebase.auth().createUserWithEmailAndPassword(email, password)
 }
catch (error) {
 console.log(error.toString())
}
}

loginUser = (email, password) => {
try {

firebase.auth().signInWithEmailAndPassword(email, password).then(function (user) {
console.log(user)
})
}
catch (error) {
 console.log(error.toString())
}
}
}
}
    
asked by Francisco Navarrete 24.05.2018 в 18:10
source

1 answer

1

Use React Navigation , once the screen is part of the navigation stack, you only have to access through the props and make use of the navigate function to go to the screen you want, a small example:

   //Creas tu stack de navegacion:
        import {
          StackNavigator,
        } from 'react-navigation';

        const App = StackNavigator({
          Home: { screen: HomeScreen },
//La llave del objeto es el identificador del screen y lo vas a usar en el navigation.
          Profile: { screen: ProfileScreen },
        });

and on the screen where you do the validation, just call this.props.navigation and then the function navigation, example:

     const { navigate } = this.props.navigation;
        return (
          <Button
            title="Go to Jane's profile"
            onPress={() =>
//El primer parametro indica el identificador de la pantalla a la que quieres ir.
              navigate('Profile')
            }
    
answered by 01.06.2018 / 11:29
source