简体   繁体   English

React Native Modal 可见 prop 什么都不做

[英]React Native Modal visible prop does nothing

Hello I am trying to put a simple react native modal in my react native app (running it on expo) but it is always visible.您好,我正在尝试在我的 react native 应用程序中放置一个简单的 react native 模态(在 expo 上运行它),但它始终可见。 When I set the visible prop to false, it still displays.当我将 visible 道具设置为 false 时,它仍然显示。 The relevant code is below:相关代码如下:

Main Component主要部件

import React, {Component} from 'react';
import {View, Text, Modal} from 'react-native';

class Home extends Component {
render() {
    return (
      <View>
        <Modal visible={false}>
          <Text>Test</Text>
        </Modal>
      </View>
    );
  }
}

package.json package.json

"dependencies": {
    "expo": "~37.0.3",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
    "react-native-web": "~0.11.7",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5"
  },

Basically the modal is always displaying, even though visible is set to false.基本上,模式总是显示,即使可见设置为 false。 Am I missing something here?我在这里错过了什么吗?

I try many ways want to found the problem.我尝试了很多方法想找到问题。 The result is:结果是:

It seems couldn't work correct on "web site" show, but work on ios or Android emulator.在“网站”节目中似乎无法正常工作,但在 ios 或 Android 模拟器上工作。

I try your code on Doc could work, but on sandbox(web site) couldn't.我在Doc上尝试您的代码可以工作,但在沙盒(网站)上却不能。

Maybe you could change to try on other emulator or Expo except "web apps" like "expo ios" or "expo Android"?也许您可以更改以尝试其他模拟器或 Expo,但“expo ios”或“expo Android”等“网络应用程序”除外?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM