5

I am trying to add my local directory image into the leftAvatar but cant achieve it, also there is no such document hint for doing so.Any help would be really appreciated. This is my render method-

render() {
    return (
      <View>
        <FlatList
          data={this.state.data}
          renderItem={({ item }) => (
            <ListItem
              leftAvatar={{
                source: { uri: "../assets/images/classboard.png" },
                showEditButton: false
              }}
              title={`${item.className} ${item.section}`}
              subtitle={item.countStudents.toString()}
              containerStyle={{ borderBottomWidth: 1 }}
            />
          )}
          keyExtractor={item => item.classId.toString()}
          // ItemSeparatorComponent={this.renderSeparator}
          // ListHeaderComponent={this.renderHeader}
          // ListFooterComponent={this.renderFooter}
          // onRefresh={this.handleRefresh}
          // refreshing={this.state.refreshing}
          // onEndReached={this.handleLoadMore}
          // onEndReachedThreshold={50}
        />
      </View>
    );
  }
}
arjayosma
  • 540
  • 3
  • 15
Kartik Saraf
  • 115
  • 1
  • 8

2 Answers2

8

If you want to use your local resource you can do this:

source: require("../assets/images/classboard.png"),

Tell me if this is what you're looking for.

arjayosma
  • 540
  • 3
  • 15
0

for local image in react native avatar use this

<Avatar.Image source={require("../images/a.jpg")} size={50} />
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Muhammad Awais
  • 109
  • 1
  • 3