reactjs - React Native Modal 可见 prop 什么都不做
问题描述
您好,我正在尝试在我的 react native 应用程序中放置一个简单的 react native 模态(在 expo 上运行它),但它始终可见。当我将 visible 道具设置为 false 时,它仍然显示。相关代码如下:
主要部件
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>
);
}
}
包.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"
},
基本上,模式总是显示,即使可见设置为 false。我在这里错过了什么吗?
解决方案
我尝试了很多方法想找到问题。结果是:
在“网站”节目上似乎无法正常工作,但在 ios 或 Android 模拟器上工作。
我在Doc上尝试您的代码可以工作,但在沙盒(网站)上却不能。
也许您可以更改以尝试除“expo ios”或“expo Android”之类的“网络应用程序”之外的其他模拟器或Expo?
推荐阅读
- django - 使用 AWS 在特定路径下提供单页应用程序
- python - Truble 在 python 中为数独创建矩阵
- c# - 如何根据gremlin中节点的属性过滤值
- node.js - 一个角度组件如何在不手动刷新整个页面的情况下告诉另一个组件刷新
- python - 如何从 python 中的另一个 .py 文件访问全局变量?
- spring-boot - 为什么 isEmpty() 不检查 null?
- sql-server - 使用 mssql 模块的 node.js 程序 - 连接到 SQL Server 数据库失败
- linux-kernel - CentOS 7 - 在 nvme 设备上从 3.10 内核更新到 5.x 后无法启动
- r - 关于所有列,如何对整个数据框进行排序
- r - 根据多个标准对ggplot中的离散x轴进行排序