Im using galio's radio component this here. Im trying to select only one value at a time. I try to achieve that with this code:
const [selected, setSelected ] = useState(false);
const OptionList = (groupOption) => {
return (
<FlatList
data={groupOption.options}
keyExtractor={(result) => result.id.toString()}
renderItem={({ item }) => {
return (
<View>
<Radio label={item.description} onChange={() => setSelected(true)} initialValue={selected} />
</View>
);
}}
/>
);
};
But since its in a flat list it changes the value for all of them. How can i only select one radio button at a time? Any ideas?
Use Radio Group or save the selected index in the state, when the user clicks on the radio button, change that selected index and mark it selected.