I am doing a simple quiz in my app with questions I'm putting in, I made 2 radio buttons as a trial, and then I made the on press function take the value of the pressed button, then test whether it's equal to the correct value, yet it's not working correctly, it sometimes alerts "good job" and sometimes "not correct" on both buttons. Here is the code :
import * as React from 'react';
import RadioForm from 'react-native-simple-radio-button';
import {
Image, Platform, StyleSheet, Text, TouchableOpacity, View, radio, Alert, Button,
ScrollView
} from 'react-native';
var radio_props = [
{ label: 'one', value: 1 },
{ label: 'two', value: 2 }
];
class Quiz extends React.Component {
state = {
value1: 0,
correct1: 0,
}
checkquestion(value) {
this.setState({ correct1: 1 })
this.setState({ value1: value })
if (this.state.value1 === this.state.correct1) {
Alert.alert("goodk job")
}
else {
Alert.alert("not correct")
}
}
render() {
return (
<View>
<Text>Choose number one</Text>
<RadioForm
radio_props={radio_props}
onPress={(value) => { this.checkquestion(value) }}
/>
</View>
)
}
}
export default Quiz
`
Uncaught SyntaxError: Cannot use import statement outside a module