0

I found similar questions but nothing works. If I click a list item I get error "undefined is not a function this.state.datasource.slice()"

I try to make all "ordered" true

Zoe
  • 23,712
  • 16
  • 99
  • 132
ditsikts
  • 236
  • 1
  • 2
  • 9

2 Answers2

0

Assuming you really want to slice your array -> Try:

this.state.dataSource.slice(1,2)

according to this you have to define a beginning and an end to slice like so:

arr.slice([begin[, end]])
dv3
  • 3,513
  • 5
  • 22
  • 47
  • If I remove slice I get "rowHasChange true "/n" defaultGetRowData true "/n" true "/n" defaultGetSectionHeaderData true "/n" and some more trues. (i put /n to show that its change line) check this link the accepted answer http://stackoverflow.com/questions/31738671/react-native-updating-list-view-datasource – ditsikts Aug 26 '16 at 19:07
  • What are you trying to achieve? hard to help you with just error messages and no guidance – dv3 Aug 26 '16 at 19:27
  • I try to change some values on datasource i this case to make all "ordered" ="true" – ditsikts Aug 26 '16 at 19:33
0

If you looked at the ListView documentation, when you initialize the dataSource for your ListView component, you can supply a method that tells the ListView if the dataSource has changed, so that the ListView will re-render.

constructor() {
  super();
  const ds = new ListView.DataSource({rowHasChanged: (e1, e2) => e1 !== e2});
  this.state = {
    dataSource: ds.cloneWithRows([/* initial data */]),
  };
}
Mμ.
  • 7,026
  • 3
  • 22
  • 32