Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i set local directory image in leftAvatar of ListItem using react-native-elements?

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>
    );
  }
}
like image 659
Kartik Saraf Avatar asked Feb 26 '19 07:02

Kartik Saraf


1 Answers

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.

like image 129
arjayosma Avatar answered Sep 29 '22 19:09

arjayosma