Reputation: 7919
I'm using Ant Desing Radio with react js for creating a radio button. and i create a Radio button like this with map function :
<RadioGroup onChange={this.setActivityType} defaultValue={this.props.activityTypes[0].value} size="large">
{this.props.activityTypes.map((type,i)=>(
<RadioButton key={i} value={type.value} >{type.name}</RadioButton>
))}
</RadioGroup>
also in onChange={this.setActivityType}
function i can see e.target.value
that is passed as value={type.value}
i also need name of between tag of <RadioButton>
, the {type.name}
but i can't see any properties in developer tools or antd docs ? dose anyone know how to access this property and save it to state with onChange?
Upvotes: 1
Views: 1269
Reputation: 104459
To access the name of each RadioButton
define a name property with each RadioButton
like this:
<RadioButton key={i} value={type.value} name={type.name}>{type.name}</RadioButton>
Now inside onChange
method access that name by e.target.name
.
Upvotes: 2