MBehtemam MBehtemam - 2 years ago 74
React JSX Question

Getting text of Radio in Ant.desing and React.js

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">

<RadioButton key={i} value={type.value} >{type.name}</RadioButton>

also in
function i can see
that is passed as
i also need name of between tag of
, the
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download