RN WebView Cannot Add a child that doesn’t have a YogaNode to a parent with out a measure function

本文提供了两种解决React Native中WebView组件出现错误的方法。第一种方案涉及检查并删除return方法内的所有注释;第二种方案建议若使用了WebView,则需确保没有被外层View包裹,以避免在Android平台上的显示问题。

这里写图片描述

解决方案1:

检查 return 方法内是否存在注释,如果有全部删除。

解决方案2:

如果使用了WebView,那么请删除外层的View视图,否则在Android上可能出现这种错误。

  render() {
    const { params } = this.props.navigation.state;
    const title = params ? params.title : null;
    const newsUrl = params ? params.url : null;

    return (
        <WebView
          style={{width:screenWidth,height:'100%'}}
          source={{uri:newsUrl}}
          startInLoadingState={true}
          domStorageEnabled={true}
          javaScriptEnabled={true}
          onError={(e)=> DetailsScreen._loadError.bind(this,e)}/>

    );
  }

ReactNative 版本 0.55

参考文档:

React native: Cannot add a child that doesn’t have a YogaNode or parent node

http://www.sunqizheng.com/blog/655.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值