Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native list view questions

I am not understanding ListView so just want to ask some questions to get a better idea of it.

In my program I have an array of dictionaries.

The dictionaries each have a title and description.

The array holding them is called partners.

I want to make a ListView that posts each title one underneath the other.

I created a constructor that looks like this (I think this is the part that is a problem)

  constructor(props){
super(props)
this.ds= new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
this.state = {
  dataSource: this.ds.cloneWithRows(partners),
}

}

Then I have a a rendow row function that looks as follows

renderRow(rowData){
return(
  <View>
  <Text>{rowData}</Text>
  </View>
  )
}

then my actual render and return function

    render () {
    return(
        <View style={styles.mainContainer}>
      <ListView
        dataSource={this.dataSource}
        renderRow={this.renderRow} />
    </View>

        )
}

Currently when I run this I get the following error

"cannot read property 'row identities' of undefined.

Thanks so much for any direction

like image 622
Adam Katz Avatar asked Jun 04 '26 18:06

Adam Katz


1 Answers

you forgot the state in this.state.dataSource

like image 187
Damathryx Avatar answered Jun 06 '26 06:06

Damathryx