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

后端 未结 14 2185
忘掉有多难
忘掉有多难 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:55

    If you have if else statement in your render() function use !! like this:

    {!! (this.state.your_state) &&
       <View>
            <Text>Your Text</Text>
       </View>
    }
    

    instead of:

    {(this.state.your_state) &&
        <View>
             <Text>Your Text</Text>
        </View>
    }
    
    0 讨论(0)
  • 2021-02-01 02:55

    I downgrade react native version, then I got a different error, basically what it was I had a simple string within a view, something like this:

    <View>
        MyComponent
    </View>
    

    I had to wrap the string with a text component like this:

    <View>
        <Text>MyComponent</Text>
    </View>
    

    hope that helps

    0 讨论(0)
提交回复
热议问题