Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

renderRow index from each row in react native

I am trying to get the current index of renderRow but I dont seem to get it. I have also tried to add i in as a variable inside renderRow. I am making highscore and it would be super convenient if I could just get the number from renderRow itself. If there is another way to get the current number each time then it will also work.

          <ListView
          dataSource={this.state.dataSource}
          renderRow={(rowData, rowID ) =>
          <Text style={styles.topStyle}>{rowID}</Text>
          }
      />
like image 965
chazefate Avatar asked Jul 14 '17 17:07

chazefate


1 Answers

The renderRow callback expects a function with 4 arguments renderRow={(rowData, sectionID, rowID, higlightRow) => { ... }}. I believe rowId is the one you need.

The docs — http://facebook.github.io/react-native/docs/listview.html#renderrow

like image 113
Dmitry Sokurenko Avatar answered Oct 20 '22 00:10

Dmitry Sokurenko