ide / react-native-button

A button for React apps
MIT License
773 stars 129 forks source link

Ability to Pass ID or Argument #8

Closed ghost closed 9 years ago

ghost commented 9 years ago

Would like to be able to pass an ID or argument to the button. For example if I do

 <Button ref="MyButton" onpress={this.buttonPressed}>Hi</Button>

I would like to be able to reference that "MyButton" was pressed allowing me to send to a single function when having multiple buttons on a screen.

ide commented 9 years ago

The way you'd do this with Button is the same how you'd do it elsewhere in React by using thunks:

<Button onPress={() => { this.buttonPressed(/*whatever you want here*/) } />
<Button onPress={this.buttonPressed.bind(this, /*whatever you want here*/)} />