YogaNode Error

0

Constantly, I'm having the error:

  

Can not add a child that does not have a YogaNode to a parent without a measure function! (Trying to add a 'ReactRawTextShadowNode' to a 'LayoutShadowNode')

I did not understand the logic of the error, so I could not fix it.

Follow my code:

import React, { Component } from 'react';
import { ScrollView, Text } from 'react-native';
import { Tile, List, ListItem } from 'react-native-elements';

class UserDetail extends Component {
  render() {
    const { id, title, whatsapp, email, phone, location } = this.props.navigation.state.params;

    return (
      <ScrollView>
        <Tile
          imageSrc={{ uri: 'https://buscafree.com.br/assets/img/items/${id}.jpg'}}
          featured
          title={title}
        />
        <List>
          {phone ? (<ListItem title="Telefone" rightTitle={phone} hideChevron />) : ''}
        </List>
      </ScrollView>
    );
  }
}

export default UserDetail;
    
asked by anonymous 09.01.2018 / 15:01

1 answer

1

This error occurs because there is some "loose" information, ie it is not inside tags.

In my case it is in line {phone ? (<ListItem title="Telefone" rightTitle={phone} hideChevron />) : ''}

When phone exists, it generates a ListItem , but when it does not exist, it generates an empty space (that's where the error is). The correct thing is to use this:

{phone ? (<ListItem title="Telefone" rightTitle={phone} hideChevron />) : '<View></View>'}

    
28.03.2018 / 02:45