2017-03-10 63 views
0

我正在为React-Native构建一个iPad应用程序,当用户单击一个按钮时,将出现一个Modal。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; 

这里的父Component

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.showPopupModal或者是truefalse但每次我点击按钮火灾editStatement我的应用程序冻结。

回答

0

这是React 0.42.0的问题,此问题已解决,因为0.42.2

相关问题