Reputation: 1974
i wrote some codes using react native listview. it rendered correctly and there weren't any errors at all; however, the listview isn't showing at all. can someone advise? below is my code. thank you very much
import React, { Component } from 'react';
import { Stylesheet, View, ListView, Text } from 'react-native';
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 != r2});
class Listvieweg extends Component {
constructor() {
super()
this.state = {
dataSource: ds.cloneWithRows([{
title: 'Why is the sky blue?',
author: 'George'
}])
}
}
renderRow(rowData) {
return (
<View>
<Text>
{rowData.title}
</Text>
<Text>
{rowData.author}
</Text>
</View>
)
}
render() {
return (
<View>
<ListView
style={styles.list}
enableEmptySections={true}
dataSource={this.state.dataSource}
renderRow={(rowData) => this.renderRow(rowData)}
/>
</View>
)
}
}
const styles = {
list: {
flex: 1
}
}
export default Listvieweg;
Upvotes: 2
Views: 1786