Last active
December 13, 2017 11:06
-
-
Save kawnayeen/132016f5fe1dfde4610eb58c887e6367 to your computer and use it in GitHub Desktop.
ListView :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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} | |
/> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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