I have this simple code in a map function to build a radiobutton:
<DataTable>
{props.options.map((o,i) =>{
return(
<>
<DataTable.Row>
<DataTable.Cell style={{flex:7}}>{o.name}</DataTable.Cell>
<DataTable.Cell style={{flex:1}}>
<RadioButton
value={i}
status={ o.sel ? 'checked' : 'unchecked' }
onPress={() =>{updateRadio(i)}}
/>
</DataTable.Cell>
</DataTable.Row>
</>
</DataTable>
with this function for update the radio:
const updateRadio = (index) => {
var temp = props.options
temp.map((o,i) =>{
if (i === index)
temp[i].sel = true
else
temp[i].sel = false
})
props.setOptions(old => [...temp])
}
props.options are this:
[{
"id": "602b883a53c89933b8238339",
"name": "Yes",
"sel": false,
"value": null
},
{
"id": "602b883a53c89933b823833a",
"name": "No",
"sel": false,
"value": null
}]
If I see the props.options it can be update correctly but the radio can't see correcly.
If I click on YES (or No the first time) I have correctly this:
with props.options:
[{
"id": "602b883a53c89933b8238339",
"name": "Yes",
"sel": true,
"value": null
},
{
"id": "602b883a53c89933b823833a",
"name": "No",
"sel": false,
"value": null
}]
Next if I check No (or YES) I have this:
with props.options:
[{
"id": "602b883a53c89933b8238339",
"name": "Yes",
"sel": false,
"value": null
},
{
"id": "602b883a53c89933b823833a",
"name": "No",
"sel": true,
"value": null
}]
Why radio can't render correctly?
EDIT:
I have found this behave:
first open button (unchecked) has border-width:2px
select and deselect (unchecked) the border-width is 20px (instead of 2px
)
reselect (checked) the border-width is 20px (instead of 2px
)