Skip to content

Instantly share code, notes, and snippets.

@socialwell-demos
Created June 23, 2022 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save socialwell-demos/6b52bcdb0893534756587c94d3811ce3 to your computer and use it in GitHub Desktop.
Save socialwell-demos/6b52bcdb0893534756587c94d3811ce3 to your computer and use it in GitHub Desktop.
React Native render list example using react.js
const renderUsersItem = ({ item }) => {
if (!item) {
return null;
}
const handlerLongClick = (id) => {
console.log(id)
}
const [first, last] = item.name.split(' ');
return (
<TouchableOpacity
style={[styles.userListWrapper, { backgroundColor: '#fff' }]}
onLongPress={() => handlerLongClick(item.id)}
onPress={() => { }}>
<View style={styles.avatarContainer}>
<Avatar.Text
size={40}
label={[first[0], last[0]]}
style={{backgroundColor: '#285e61', fontSize: 20}}
/>
</View>
<View style={styles.userColumnData}>
<Text style={styles.columnText}>{item.name}</Text>
<Text style={styles.columnTextLight} >{item.gender}</Text>
</View>
<View style={styles.userColumnData}>
<Text style={styles.columnText}>{item.address}</Text>
<Text style={styles.columnText}>{item.country}</Text>
</View>
<View style={styles.userColumnData}>
<Text style={styles.columnText}>{item.mobileNo}</Text>
<Text style={styles.columnText}>{item.email}</Text>
</View>
<View style={styles.userColumnData}>
<Text style={styles.design}>{item.tag}</Text>
</View>
</TouchableOpacity>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment