React-native-swipe-list-view: onPress method called at render

Created on 19 Apr 2016  路  6Comments  路  Source: jemise111/react-native-swipe-list-view

If I do something like this, my onPress method gets call for every rows at render.

renderHiddenRow={(rowData, secId, rowID) => (
  <TouchableHighlight onPress={this._handleRemoveIdea(rowID)} style={styles.rowBack}>
    <Text style={styles.rowBackText}>Delete</Text>
  </TouchableHighlight>
)}

Most helpful comment

I think this is because you're actually calling the function when the onPress handler is bound to the TouchableHighlight. Could you give something like this a try:

<TouchableHighlight onPress={ _ => this._handleRemoveIdea(rowID) } style={styles.rowBack}>

Let me know if that does the trick otherwise I'll investigate further

All 6 comments

I think this is because you're actually calling the function when the onPress handler is bound to the TouchableHighlight. Could you give something like this a try:

<TouchableHighlight onPress={ _ => this._handleRemoveIdea(rowID) } style={styles.rowBack}>

Let me know if that does the trick otherwise I'll investigate further

Thanks, I will try that tonight and will let you know

It works great. thanks

@jemise111 your solution works great :) Thanks a lot

@jemise111 Thanks a lot for your solution and its explanation.

@jemise111 It works, thanks a lot. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

baicuhaha picture baicuhaha  路  6Comments

alexco2 picture alexco2  路  6Comments

grigy picture grigy  路  4Comments

jjhesk picture jjhesk  路  3Comments

nzrin picture nzrin  路  5Comments