美文网首页
Cannot add a child that doesn't

Cannot add a child that doesn't

作者: 既然可以颠覆何必循规蹈矩 | 来源:发表于2018-05-08 19:46 被阅读0次

    勤做笔记,方便自己,帮助他人。

    Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a 'ReactRawTextShadowNode' to a 'LayoutShadowNode') addChildAt ReactShadowNodeImpl.java:199 addChildAt ReactShadowNodeImpl.java:54 setChildren

    错误1

    废话不多说 旧代码

    {
      data.face&&
      <TouchableOpacity onPress={()=>this.delImg('face')} style={styles.delImg}>
        <Image source={require('../../images/shanchu.png')}  />
      </TouchableOpacity>
     }
    

    废话不多说 新代码

    {
      data.face?
      <TouchableOpacity onPress={()=>this.delImg('face')} style={styles.delImg}>
        <Image source={require('../../images/shanchu.png')}  />
      </TouchableOpacity>
      :null
     }
    

    错误2

    该错误一般是因为render方法中注释语句写法不正确,render的return函数里面的注释语句应该写在 {} 里面,而不是直接 //,正确写法:{/*注释语句 */}

    最全的解释:https://github.com/facebook/react-native/issues/13243#issuecomment-335488473

    相关文章

      网友评论

          本文标题:Cannot add a child that doesn't

          本文链接:https://www.haomeiwen.com/subject/kqgwrftx.html