I am very new on React Native , I don't know how to change these type class functions , i am working on functional component that's why i need to change this into functional.
state = {
selectedIndex: 0,
radioButtonValue: 'asc',
};
onPress = (index) => {
this.setState({
selectedIndex: index,
});
};
onRadiochange = (index, value) => {
this.setState({
radioButtonValue: value,
selectedIndex: index,
});
};
error in code can't find variable onPress
code for style
<RadioButton.Group onValueChange={(value) =>
onRadiochange(index, value)
}>
<View style={styles.singleRadioButtonContainer}>
<Text>Yes</Text>
<RadioButton
color="#5d86d7"
value="1"
status={
state.selectedIndex === index &&
state.radioButtonValue === '1'
? 'checked'
: 'unchecked'
}
onPress={() => {onPress(index)}}
/>
</View>