2017-07-12 9 views
0

私はreact-native-modalboxを使用しています。反応ネイティブでモーダルを閉じるには

ScreenAからScreenBを開きたいとします。

ScreenBを開いた後でScreenAを終了します。

誰でも解決方法を知っていますか?

import Modal from 'react-native-modalbox'; 
import ScreenB from './ScreenB'; 

class ScreenA extends React.Component { 

render() { 
    return (
     <View> 
      <Modal 
       ref={"modal1"} 
       swipeToClose={true} 
       coverScreen={true} 
      ><ScreenB></ScreenB> 
      </Modal> 
      <View> 
       <TouchableOpacity 
        onPress={() => this.refs.modal1.open()}> 
        <Text>Click me</Text> 
       </TouchableOpacity> 
      </View> 
     </View> 
    ); 
} 

}

答えて

0

新しいページを表示するモーダルな方法を使用して見えます。それは新しいページに置き換えて異なっています。通常、モーダルは一時的なページを表示するために使用します。

ページをaからbに変更してaを閉じる場合は、ReactNavigator またはReact Native Routerを使用することをお勧めします。次に、モーダルアニメーションで置き換えるオプションを探します。

1
/*********/ 
$<Modal transparent={true} visible={ this.props.loading } 
        onRequestClose={() => {this._setModalVisible(false)}}> 
        {loading} 
      </Modal> 

_setModalVisible(visible) { 
     this.setState({loading: visible}) 
    }$ 
/***********/ 
関連する問題