haga clic aquí para ver el resultado que necesito
Soy principiante en reaccionar nativo.
Cuando selecciono la primera pregunta, la opción se selecciona y se almacena en el estado.
Luego selecciono la segunda pregunta, la opción se almacena en el estado pero antes de que el valor seleccionado no esté en el estado.
Además, si selecciono la opción de la primera pregunta, Sí , luego selecciono la opción de la segunda pregunta, Sí , y nuevamente si selecciono la opción de la primera pregunta, No , pero antes de seleccionar la opción de la primera pregunta, se debe eliminar del estado.
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> ); }