首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >React-Native 遇到的错误1. React-Native 部分组件在debug模式下打包在iOS真机上可以显示,但是release模式下打包在iOS真机上不显示2. React-Native

React-Native 遇到的错误1. React-Native 部分组件在debug模式下打包在iOS真机上可以显示,但是release模式下打包在iOS真机上不显示2. React-Native

作者头像
贺贺V5
发布2018-08-21 14:37:37
1.8K0
发布2018-08-21 14:37:37
举报

1. React-Native 部分组件在debug模式下打包在iOS真机上可以显示,但是release模式下打包在iOS真机上不显示

显示

不显示

这个问题真的是卡了我好久,只要是打release包,下面的按钮组就是不显示,而release包又不能调试,于是我终于在忍无可忍的情况下,一直不能打包然后一点一点的展示在页面上,来看到底是哪里的问题。终于让我定位到了问题的所在。

问题出在这:

let buttons = [];
children.forEach((child, i) => {
      if (child.type.name === 'FlowSendButton') {
        const buttonConfig = FlowSendButton({
          setShowWriteNotion: this.setShowWriteNotion,
          requireNotion: child.props.requireNotion,
          ...child.props,
        });
        if (this.getShow(child.props)) {
          buttons.push(buttonConfig);
        }
      } else if (child.type.name === 'FlowNotionButton') {...}
...
});

这段代码在release包的情况是,buttons是空的,是由于if (child.type.name === 'FlowSendButton')这是判断根本不会为true,因为在release模式下,child.type根本没有name这个属性,只有在debug模式下才有,所以这样来进行判断的 ,统统不会有true的情况,自然buttons中没有值,也就不会展示了。

下面是我找到的一些文档中的交流:

判断方式

release

debug

if (child.type.displayName === 'FlowCancelDoButton') {}

失效

有效

if (child.type.name === 'FlowCancelDoButton') {}

失效

有效

if (child.type.prototype instanceof FlowCancelDoButton) {}

失效

有效

if (child.type === FlowApproveButton) {}

有效

有效

判断方式一览表

判断方式

release

debug

if (child.type.displayName === 'FlowCancelDoButton') {}

失效

有效

if (child.type.name === 'FlowCancelDoButton') {}

失效

有效

if (child.type.prototype instanceof FlowCancelDoButton) {}

失效

有效

if (child.type === FlowApproveButton) {}

有效

有效

总结

2. React-Native 启动时报错 - “no bundle url present”

原因

我运行了react-native run-android看了一下安卓环境下的图标的样式,然后使用react-native run-ios就报错了no bundle url present这个错误,我什么都没有干啊。

error

图片上的错误就不停,度娘了一下,原来是,因为我开了两个环境吧,可是我把环境都关了,还是不行。

解决

于是我就在iOS模拟器正在运行期间执行了:

npm install
react-native run-ios

zz,一遍还不行,试了两遍才正常了!!!


若干天后,又遇到了这个问题,按照上面的方式试了好多次都不行,只能关机重启,就好了。~~~(>_<)~~~ zz

RawText "/*" must be wrapped in an explicit <Text> component错误

是因为<Text>{test}</Text>中的test被这是为了空字符串'',就会报这个错,要保证test不会被设置为''.

ReactNative js调试时变得很卡

解决办法

把那个chrome的Tab页保持最前,窗口不要最小化就好了。也就是下面这个页面不要关,保持在最前面就好了。

js slow.png

一直报[...effects] has been deprecated in favor of all([...effects]), please update your code这个警告。

解决办法

只需要这样更新代码即可

fix.png

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017.04.30 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. React-Native 部分组件在debug模式下打包在iOS真机上可以显示,但是release模式下打包在iOS真机上不显示
    • 总结
    • 2. React-Native 启动时报错 - “no bundle url present”
      • 原因
        • 解决
        • RawText "/*" must be wrapped in an explicit <Text> component错误
        • ReactNative js调试时变得很卡
          • 解决办法
          • 一直报[...effects] has been deprecated in favor of all([...effects]), please update your code这个警告。
            • 解决办法
            领券
            问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档