Instantly share code, notes, and snippets.

Embed
What would you like to do?
export default class App extends Component {
constructor(){
super()
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
this.state = {
dataSource: ds.cloneWithRows([]),
rawData: ''
}
}
componentWillMount() {
this.fetchData()
}
fetchData(){
fetch(url)
.then((res) => res.json())
.then((data) => {
this.setState({
dataSources: this.state.dataSource.cloneWithRows(data),
rawData: data
})
})
}
render(){
<View style={styles.container}>
<InputText
style={styles.inputText}
/>
<ListView
style={styles.listView}
enableEmptySections={true}
dataSource={this.state.dataSource}
/>
</View>
}
}
const styles = StyleSheet({...})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment