【问题标题】:React-Native Modal hangs upReact-Native Modal 挂了
【发布时间】:2019-07-10 22:46:46
【问题描述】:

import React from 'react';
import { View, Text, Modal, Image, Button, StyleSheet } from 'react-native';

const ModalBox = props => {
    let ModalContent = null;
    if (props.selectedPlace) {
        ModalContent = (
            <View>
                <Image source={props.selectedPlace.image} style={styles.image} ></Image>
                <Text style= {styles.text}>{props.selectedPlace.value}</Text>
            </View>
        )
    }
    return (
        <Modal onRequestClose={props.close} visible={props.selectedPlace !== null} animationType="slide">
            <View style={styles.ModalContainer}>
                {ModalContent} 
                <Button title="Delete" color="red" onPress={props.itemDelete}></Button>
                <Button title="Close" onPress={props.close}></Button>
            </View>
        </Modal>
    )
}

const styles = StyleSheet.create({
    ModalContainer: {
        marginTop: 10
    },
    image: {
        height:200,
        width: "100%"
    },
    text:{
        textAlign:"center",
        fontWeight:"bold",
        fontSize: 28
    }
})

export default ModalBox;

我有上面的模态代码。 当我打开我的模态然后对我的代码进行一些更改然后重新加载它时。 Modal 挂断了,甚至无法单击我的按钮并重新加载应用程序。我必须关闭我的应用程序然后重新开始。

【问题讨论】:

  • 我也有同样的问题

标签: react-native react-native-android


【解决方案1】:

问题不在于您的代码,而在于 React Native Modal itself。它已在多个版本中出现。最著名的解决方法是使用像 react-native-navigation 这样的库,它有自己的模式实现。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-01
    • 2019-06-26
    • 2020-03-15
    • 2020-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多