Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Extended answer based on discussion
Source Link
NiFi
  • 2.5k
  • 1
  • 19
  • 26

One solution is to pass that info as a parameter:

<MKRadioButton title='A' group={this.radioGroup} onPress={(event) => this._toggle(event, 'A')} /> 

The callback would then use that parameter

_toggle(event, buttonId) { // Use buttonId } 

EDIT: Another solution is a parent component that always returns the title prop:

class RadioParent extends Component { render() { return ( <MKRadioButton title={this.props.title} group={this.props.radioGroup} onPress={(event) => this.props.onPress(event, this.props.title)} /> ); } } 

One solution is to pass that info as a parameter:

<MKRadioButton title='A' group={this.radioGroup} onPress={(event) => this._toggle(event, 'A')} /> 

The callback would then use that parameter

_toggle(event, buttonId) { // Use buttonId } 

One solution is to pass that info as a parameter:

<MKRadioButton title='A' group={this.radioGroup} onPress={(event) => this._toggle(event, 'A')} /> 

The callback would then use that parameter

_toggle(event, buttonId) { // Use buttonId } 

EDIT: Another solution is a parent component that always returns the title prop:

class RadioParent extends Component { render() { return ( <MKRadioButton title={this.props.title} group={this.props.radioGroup} onPress={(event) => this.props.onPress(event, this.props.title)} /> ); } } 
Source Link
NiFi
  • 2.5k
  • 1
  • 19
  • 26

One solution is to pass that info as a parameter:

<MKRadioButton title='A' group={this.radioGroup} onPress={(event) => this._toggle(event, 'A')} /> 

The callback would then use that parameter

_toggle(event, buttonId) { // Use buttonId }