Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React NavigatorIOS not updating title on replace()

Tags:

react-native

I'm using a NavigatorIOS component in my root component, and want to toggle between a login an register screen:

navToLogin() {
    this.refs.nav.replace({
        title: "Login",
        component: LoginScene,
        rightButtonTitle: "Sign Up",
        onRightButtonPress: this.navToRegister.bind(this)
    });
}

navToRegister() {
    this.refs.nav.replace({
        title: "Sign Up",
        component: RegisterScene,
        rightButtonTitle: "Login",
        onRightButtonPress: this.navToLogin.bind(this)
    });
}

render() {
    return (
        <NavigatorIOS
            ref = "nav"
            style={styles.navigator}
            initialRoute={{
                component: LoginScene,
                title: "Login",
                rightButtonTitle: "Sign Up",
                onRightButtonPress: this.navToRegister.bind(this)
            }}
        />
    );
}

Although the view is updated properly, the title and rightButton do not change after the nav.replace() invocation. When I'm using nav.push() everything works as expected.

Am I using this component wrong somehow?

like image 346
tkers Avatar asked Apr 21 '15 09:04

tkers


1 Answers

You're not using it wrong, this is a bug NavigatorIOS. If you can it's probably worth using Navigator instead as that's better supported (Facebook are actually using it themselves internally)

like image 170
Thomas Parslow Avatar answered Nov 18 '22 00:11

Thomas Parslow