Skip to content

Instantly share code, notes, and snippets.

@kawnayeen
Last active December 13, 2017 11:06
Show Gist options
  • Save kawnayeen/132016f5fe1dfde4610eb58c887e6367 to your computer and use it in GitHub Desktop.
Save kawnayeen/132016f5fe1dfde4610eb58c887e6367 to your computer and use it in GitHub Desktop.
ListView :)
// constructor
constructor() {
super();
this.employees = [
{'name': 'Himel'},
{'name': 'Rana'},
{'name': 'Shuvro'},
{'name': 'Proshad'}
];
}
componentWillMount() {
this.createDataSource();
}
createDataSource(){
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
});
this.dataSource = ds.cloneWithRows(this.employees);
}
renderRow(employee) {
return <MemberListItem employee={employee}/>;
}
// in render
return (
<ListView
enableEmptySections
dataSource={this.dataSource}
renderRow={this.renderRow}
/>
);
import React, { Component } from 'react';
import { Text, View, TouchableWithoutFeedback } from 'react-native';
import CardSection from './card.section';
class MemberListItem extends Component {
onRowPress() {
}
render() {
const { name } = this.props.employee;
return (
<TouchableWithoutFeedback onPress={this.onRowPress.bind(this)}>
<View>
<CardSection>
<Text style={styles.titleStyle}>
{name}
</Text>
</CardSection>
</View>
</TouchableWithoutFeedback>
);
}
}
const styles = {
titleStyle: {
fontSize: 18,
paddingLeft: 15
}
};
export default MemberListItem;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment