Reputation: 883
I have a buttons and i want to get the name prop of the button when a button is pressed. I am going to doing this as follows and i am getting a number instead of the name prop how can i achieve this
Button
<StatusOption
name="On going"
onPress={e => this.onChanged(e)}
>
onChanged = (e) => {
console.log(e.target);
};
How i am able to do so in react native
Upvotes: 0
Views: 244
Reputation: 15292
Alongwith e
you can pass the second parameter as a prop name.
<StatusOption
name="On going"
onPress={e => this.onChanged(e,"On going")} >
^^^^^^^^
And in onChanged
access it
onChanged = (e,propName) => {
console.log(e.target,propName);
};
Upvotes: 3