2017-03-10 23 views
0

ユーザーがボタンをクリックしてからモーダルを表示すると、React-Nativeを使用してiPad用のアプリケーションを構築しています。Reactネイティブアプリケーションが応答しなくなる/状態変更時にクラッシュする

モーダルの開始ライフが隠されている場合、親コンポーネントはstateブール変数を設定して、モーダルを表示するかどうかを決定します。

ここに私のコードは、まだ使用されていないインポートを無視してください。

import React, { Component } from "react"; 
import { StyleSheet, View, Modal, Text, Button } from "react-native"; 

const PopupModal = props => { 
    console.log(props); 
    return (
    <Modal transparent={true} visible={props.visible}> 
     <View 
     style={{ 
      backgroundColor: "rgba(0,0,0,.5)", 
      flex: 1, 
      justifyContent: "center", 
      alignItems: "center" 
     }} 
     > 
     <View 
      style={{ 
      height: 386, 
      width: 355, 
      backgroundColor: "#FFF", 
      borderRadius: 10, 
      }} 
     > 
      <Button onPress={() => {}} title="Save" /> 
     </View> 
     </View> 
    </Modal> 
) 
} 

export default PopupModal; 

はここで、親コンポーネント

class Home extends Component { 
    constructor() { 
    super(); 
    this.state = { 
     videos: [], 
     offset: { 
     y: 0, 
     x: 0 
     }, 
     showPopupModal: false, 
     selectedVideo: { 
     id: null, 
     reflectiveStatement: null, 
     } 
    }; 
    } 
    editStatement = (id, reflectiveStatement) => { 
    this.setState({ 
     showPopupModal: true, 
     selectedVideo: { 
     id, 
     reflectiveStatement, 
     } 
    }) 
    } 
    render() { 
    return (<PopupModal visible={this.state.showPopupModal} /> 
    } 
} 

export default Home; 

this.state.showPopupModaltruefalseのいずれかであるだが、毎回私は、ボタンの火災にeditStatement自分のアプリケーションがフリーズをクリックしてください。

答えて

0

これはReact 0.42.0の問題で、この問題は0.42.2

で解決されています
関連する問題