const [gender,setgender]=useState()
const handlegender=(e)=>{
setgender(e.target.value)
}
<form>
<div>
<label>Gender</label>
<input type="radio" name="gender" value="male" onChange={handlegender} />
Male
<input type="radio" name="gender" value="Female" onChange={handlegender}/>
Female
</div>
</form>
class App extends React.Component {
setGender(event) {
console.log(event.target.value);
}
render() {
return (
<div onChange={this.setGender.bind(this)}>
<input type="radio" value="MALE" name="gender"/> Male
<input type="radio" value="FEMALE" name="gender"/> Female
</div>
)
}
}
ReactDOM.render(<App/>, document.getElementById('app'));
function App() {
return (
<div>
<label className="radio">
<input name="radio" type="radio" checked/>
<span>Awesome</span>
</label>
<label className="radio">
<input name="radio" type="radio" />
<span>Cool</span>
</label>
</div>
);
}
export default App;