click here to see output i need
I am beginner in react native.
When I select the 1st question, option is selected and stored in state.
Then I select the 2nd question, option is stored in state but before selected value is not in state.
Also, if I select the 1st question option Yes, then I select the 2nd question option Yes, and again if I select 1st question option No but before I select the 1st question option must be removed in state.
myArray = [
{
isSignReq: 1,
name: "You are hereby given the opportunity to read and understand the",
sno: 1,
yesno: 0,
},
{
isSignReq: 1,
name: "Your Full wages commence from the day of departure from last international",
sno: 2,
yesno: 0,
},
{
isSignReq: 1,
name: "The company shall bear or reimburse cost for obtaining necessary
Flag documents",
sno: 3,
yesno: 0,
},
{
isSignReq: 1,
name: "Company has the right to recover the cost of training, interview
and evaluations.",
sno: 4,
yesno: 0,
},
{
isSignReq: 1,
name: "Company follows strict Drug and alcohol Policy and any abuse on
board will result.",
sno: 5,
yesno: 0,
},
{
isSignReq: 1,
name: "Ships may trade through any High Risk area including Gulf of Aden and West African.",
sno: 6,
yesno: 0,
},
]
import React, { useState } from 'react';
import RadioForm from 'react-native-simple-radio-button';
import { StyleSheet, Text, View } from 'react-native';
export default function App() {
const [isChecked, setIsChecked] = useState([])
var radio_props = [{ label: "Yes", value: 1 }, { label: "No", value: 2 }];
return (
<View style={styles.container}>
{
myArray.map((values, index) => {
return (
<View key={index.toString()}>
<RadioForm
radio_props={radio_props}
initial={null}
onPress={(value) => {
setIsChecked({status:value, data:values})
}}
/>
</View>
)
})
}
</View>
);
}