Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListItem is not showing text from the "title" property in React Native

I'm using ListItem from react native elements in a FlatList, the code is

  render() {
    return (
      <View style={commonStyles.container}>
        <List>
          <FlatList
            data={this.props.questions}
            renderItem={({ item }) => (
              <ListItem
                roundAvatar
                title={'nicola'}
              />
            )}
          />
        </List>
      </View>
    );
  }

The issue is that text ( 'nicola' ) is not rendered

enter image description here

like image 940
Nicola Peluchetti Avatar asked Oct 16 '25 06:10

Nicola Peluchetti


2 Answers

Edit 03/04/2022

The new syntax is available here : https://reactnativeelements.com/docs/components/listitem

I know this is quite late, but I had encountered the same issue.

const list = [
{
    name: 'Account',
    icon: 'av-timer'
},
{
    name: 'Category',
    icon: 'flight-takeoff'
},
{
    name: 'About',
    icon: 'av-timer'
}]

... // some code here

   <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
    {
        list.map((item, i) => (
            <ListItem
                key={i}
                title={item.name}
                leftIcon={{ name: item.icon }}
            />
         ))
    }
   </View>

When I used the above code, only icons were shown, but the issue was resolved when I removed alignItems prop.

like image 186
James Yoo Avatar answered Oct 17 '25 19:10

James Yoo


Remove

alignItems: "center"

in View

like image 28
Aamer Avatar answered Oct 17 '25 19:10

Aamer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!