I want to call a function inside a Scene's component when I press the right button of a navigation bar.
In parent:
<Router
style={routerStyle.router}
navigationBarStyle={navBarStyle.navBar}
titleStyle={navBarStyle.navTitle}
leftButtonStyle={navBarStyle.leftButtonStyle}
drawerImage={hamburgerIcon}>
<Scene
key='History'
component={History}
title='History'
type='reset'
rightButtonImage={mailIcon}
onRight={this.sendMail} <-- ON THIS
rightButtonStyle={navBarStyle.rightButtonStyle}
rightButtonIconStyle={navBarStyle.rightButtonIconStyle} />
</Router>
In child (History.js):
openModal() {
this.setState({modalVisible: true}); <-- DO THIS
}
closeModal() {
this.setState({modalVisible: false});
}
You can use Actions.refresh to refresh props of active scene. I have used it as an escape hatch when stuck with this router package.
Be aware of when and why componentWillReceiveProps so you don't call toggleModal unintentionally, though.