listview - Disable a specific Button on click in react native -
i have list of buttons on react native (around 3000 buttons) listed on listview component.
how disable button number 365 on button click?
you have not mentioned key point here, how plan disable button? want disable button in response action or want disable button by-default? please specify. i'm assuming few things here-
- you want disable button upon action, have maintain state.
- you have used
touchablehighlight
ortouchablewithoutfeedback
use rowid
intelligently disable exact item. populate array of disaled ids , accordingly disable item.
your render method renders listview
render: function(){ return( <listview datasource={this.state.datasource} renderrow={(rowdata, sectionid, rowid) => renderitem.bind(this, rowid)} style={styles.listview} /> ); }, renderitem: function(id){ return <item id={id} enabled={this.state.isenabled} data={{name: 'foo', details: 'bar'}} /> }
item component have own functions , state , props.
render: function(){ return( <touchablehighlight underlaycolor={'#939393'} onpress={this.onpressitem}> <view style={styles.container}> <text>{this.props.data.name}</text> <text>{this.props.data.details}</text> </view> </touchablehighlight> ) }, onpressitem: function(){ if(this.props.enabled){ //do } else{ //do nothing } }
Comments
Post a Comment