react-native - 启动反应本机应用程序时出现异常
问题描述
我无法找到我做错的地方
当我运行 Metro bundler 时会发生这种情况
BUNDLE [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1491/1491), done.
LOG Running "Trepr" with {"rootTag":1}
WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at render (http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:183726:35)
at finishClassComponent (http://10.0.3.2:8081/index.bundle?platform=android&dev=true&minify=false:17810:43)
解决方案
您可以尝试获取数组legnth
的属性。null
所以你需要这样编码..
array !== null && array !== undefined && array.length
推荐阅读
- opayo - 直接协议 4.00 - ThreeDSRequestorPriorAuthenticationInfo.threeDSReqPriorRef - 我如何填充它?
- python - 从数据框中获取值到一系列 Web API 请求中
- asp.net - 希望 Forms 和 Windows 身份验证在组合模式下工作
- angular - 仅显示 *ngIf 表达式的第一个匹配项
- javascript - 如何合并多个draft-js ContentState
- android - 通过Picasso lib by image url在android新设备中的图像加载问题
- azure - Azure 自动化中的多个 RunAs 帐户
- oracle - 我需要每个“组”的 ID
- javascript - 为什么 Safari Content Blocker 在我的网站上单击时会阻止此重定向?
- spring-cloud-config - 如何以编程方式更新 Spring Cloud Config 客户端上的属性