模态没有出现

时间:2018-12-27 13:09:53

标签: react-native modal-dialog

我正在使用react-native-modal组件,但是该模式似乎确实在单击按钮时显示,使用的示例与“完整示例部分”中的示例相同:

将isVisible更改为可见时,它可以正常工作:

import React, { Component } from "react";
import { Text, TouchableOpacity, View } from "react-native";
import Modala from "react-native-modal";

export default class ModalTester extends Component {

state = {
   isModalVisible: false
};

_toggleModal = () =>
    this.setState({ isModalVisible: !this.state.isModalVisible });

render() {
    return (
        <View style={{ flex: 1 }}>
            <TouchableOpacity onPress={this._toggleModal}>
                <Text>Show Modal</Text>
            </TouchableOpacity>
            <Modala isVisible={this.state.isModalVisible}>
                <View style={{ flex: 1 }}>
                    <Text>Hello!</Text>
                    <TouchableOpacity onPress={this._toggleModal}>
                        <Text>Hide me!</Text>
                    </TouchableOpacity>
                </View>
            </Modala>
        </View>
    );
  }
} 

预期:  我希望模式会在点击时显示

0 个答案:

没有答案