Skip to content

[NavigatorIOS] SetState does not rerender NavigatorIOS component (w/ example repo) #1403

@the4dpatrick

Description

@the4dpatrick

Here is a repo showing the bug https://github.com/the4dpatrick/react-native-bug-example

I am trying to toggle NavigatorIOS on and off based on the prop navigationBarHidden set to a state value.

 return ( <NavigatorIOS style={styles.container} initialRoute={initialRoute} navigationBarHidden={this.state.hideNavbar} configureScene={() => Navigator.SceneConfigs.PushFromRight}/> ); 

I pass along a method to child components that passes the parent's context and toggle the state value.

 toggleNavigation() { this.setState({ hideNavbar: !this.state.hideNavbar }); } 
 initialRoute = { component: ScreenWithMenu, title: 'Screen', passProps: { toggleNavigation: this.toggleNavigation.bind(this) } }; 

Inside the sidemenu, I am calling this.props.toggleNavigation() onPress. This correctly toggles the navbar when initially hidden, but when you press onLeftButtonPress, the navbar does not toggle off.

 navigateToThemes() { var Themes = require('../Screens/Themes'); this.props.menuActions.close(); this.props.toggleNavigation(); this.props.navigator.push({ component: Themes, title: 'Themes', leftButtonTitle: 'Back', onLeftButtonPress: () => { this.props.navigator.pop(); this.props.toggleNavigation(); }, passProps: { navigator: this.props.navigator } }) } 

Here is the start of the IRC chat on this bug https://botbot.me/freenode/reactnative/2015-05-26/?msg=40122019&page=1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions