1
ナビゲーションバーの右ボタンを押したときに、シーンのコンポーネント内の関数を呼び出す必要があります。親でネイティブルータフラックスに反応する - シーンのメソッドを呼び出す方法
:子で
<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>
(History.js):
openModal() {
this.setState({modalVisible: true}); <-- DO THIS
}
closeModal() {
this.setState({modalVisible: false});
}
Actions.History({modalVisible:true})またはActions.refresh({modalVisible:true})を使用するのはどうでしょう。次に、componentWillReceivePropsの変更を監視します。 –
それは動作します!特に私は で修正しました。 'sendMail(){ Actions.refresh(); } '私のルータで、 ' componentWillReceiveProps(){ this.toggleModal(); } toggleModal(){ this.setState({modalVisible:!this.state.modalVisible}); } ' のシーンで、私はそれを受け入れることができるように答えを投稿してください:) – Haruspik