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

后端 未结 14 2181
忘掉有多难
忘掉有多难 2021-02-01 02:22

Just started learning react-native,

I have created one separate file flexdemo.js and created component as below:

import React, { Component } from \'react         


        
14条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 02:39

    I have encountered the same issue just now and solved it by removing the comments that I have made while editing the project in android studio and over there the comment's shorotcut just adds /* and */ but actually for react native the commented code should be enclosed with starting and end of curly braces, for example following would be an invalid comment:

    /*
     {
        this.state.response.map((index, value) => {
        return index.title;
        })
     }
     */
    

    And the following will be a valid one:

    {/*
     {
        this.state.response.map((index, value) => {
        return index.title;
        })
     }
     */}
    

    you see there is just one minor difference of enclosing the comment in curly braces.

提交回复
热议问题