2017-07-07 22 views
0

私のレンダー機能では、ロードを行う際に 'loading'が表示されますので、私は 'setState'を呼び出してDOMを再レンダリングします。私はモーダルを表示したいが、モーダルは表示されない。どうした俺?Dom再レンダリング時にReact-Native Modalが表示されない

render: function() { 

    if (!this.props.data) { 
      return (<View style={{flex:1}}> 
        <Text>loading</Text> 
       </View>); 
    } 
    return (
     <View style={{flex:1, width:screenWidth}}> 
     <Modal 
       visible={true} 
       transparent={true} 
       onRequestClose={()=>{ 
       }} 
       onShow={()=>{ 
       }}> 
       <View 
        style={{flex:1,justifyContent:'center',alignItems:'center',backgroundColor:'rgba(0, 0, 0, 0.3)'}}> 
        <View style={{height:200,width:275,backgroundColor:'white'}}> 
         <Button title='confirm' onPress={()=>{}}/> 
         <Button title='cancel' onPress={()=>{}}/> 
        </View> 
       </View> 
      </Modal> 
     </View> 
    ); 
} 

答えて

0

あなたが好きな、単一の見返りに状況を確認することができます。

render(){ 
    return(
     {(!this.props.data) 
     ? (<View style={{flex:1}}> 
       <Text>loading</Text> 
      </View>) 
     : (<View style={{flex:1, width:screenWidth}}> 
      <Modal/> { /*your modal code */} 
     </View>) 
     } 
    ); 
} 

まずはい、それはスタイルや再胸が張り裂ける問題であるならば、あなたのモーダルは条件なしで開くかどうか確認してください。

+0

@エリックは固定されていますか? –

+0

「予期しないトークン」というエラーが発生しました。たぶん '?:'はリターン関数で使うことができないでしょうか? – Eric

+0

あなたはそのコードを表示していただけますか? –

関連する問題