I am looking to set the value of input from state however not successful.
Here is my attempt
state={
value: ["one","two","three"]
}
render (
return(
{
this.state.value.map(val=>{
return <Input type="radio" value={val} />
})
})
)
the result I am getting is only one input element without the value displayed. as
*
What I am looking for is for three input element with there value displayed as
* One
* two
* Three
Change your render like follwong.
render() {
return (
this.state.value.map(function(val) {
return <div> <input type = "radio" value = {val}/>{val}</div>
})
)
}
Online Demo
Note: If you want that you will be able to select only one radio button, in that case you need to group the radio button together by giving a common name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With