Ulysses
Ulysses

Reputation: 123

How can i navigate from a screen inside a DrawerNavigator to an other one inside the same DrawerNavigator

When my user update his email adress (inside ChangeMail screen) i would like to redirect him to the first screen of the DrawerNavigator: 'Exercices'

I don't understand hos this.props.navigation works in this case.


const drawerNavigator = createDrawerNavigator({
    Exercices: {
        screen: stackNavigator
    },
    ResetPassword: {
        screen: ResetPassword
    },
    ChangeMail: {
        screen: ChangeMail
    },
    DeleteAccount: {
        screen: DeleteAccount
    },
    Disconnect: {
        screen: ExitScreen
    }
})


//inside the ChangeMail screen
changeEmail = (currentPassword, newEmail) => {
        this.reauthenticate(currentPassword).then(() => {
            var user = firebase.auth().currentUser;
            user.updateEmail(newEmail).then(() => {
                console.log("Email updated!");
            }).catch((error) => { console.log(error); });
        }).catch((error) => { console.log(error); }).then(() => {
            updateDatabaseEmail(newEmail)
        }).then(() => this.props.navigation.navigate("Exercice"))
          //not working

    }

Upvotes: 1

Views: 25

Answers (1)

Junius L
Junius L

Reputation: 16122

Your route name is Exercices but you are navigating to Exercice

this.props.navigation.navigate("Exercices")

Upvotes: 1

Related Questions