Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
seleccione un solo botón de radio en la lista plana nativa de reacción

Soy React Native Beginner y estoy usando expo-radio-button.

Pero no puedo seleccionar un solo botón de opción a la vez en la lista plana.

si selecciono un solo botón, seleccionará solo un botón.

ayúdame a arreglar esto. necesito mostrar y seleccionar sí o no en el botón de radio para cada pregunta

Haga clic aquí para ver la salida que quiero

 var myArray = [ { isSignReq: "1", sno: "1", yesno: "0", }, { isSignReq: "1", sno: "2", yesno: "0", }, { isSignReq: "1", sno: "3", yesno: "0", }, ]; const [account, setAccount] = useState([]); const setFormSubmit = (val) => { console.log(val); }; <FlatList data={myArray} keyExtractor={() => { return ( new Date().getTime().toString() + Math.floor(Math.random() * Math.floor(new Date().getTime())).toString() ); }} renderItem={(itemData) => { return ( <View style={{ flexDirection: "row", marginVertical: "2%" }}> <Text style={styles.data1}>{itemData.item.sno}</Text> <Text style={styles.data2}>{itemData.item.name}</Text> <View style={{ width: "30%", marginLeft: "1%" }}> <RadioButtonGroup onSelected={(value) => { setFormSubmit(value), setAccount(value); }} selected={account} size={22} containerStyle={{ flexDirection: "row" }} > <RadioButtonItem label={"Yes"} value={itemData.item.isSignReq} /> <RadioButtonItem label={"No"} value={itemData.item.yesno} /> </RadioButtonGroup> </View> </View> ); }} />
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

renderItem = ({item, index}) => { ..... <RadioButton innerColor={Colors.darkBlue} outerColor={Colors.lightGray} animation={'bounceIn'}enter code here isSelected={this.state.selectedIndex === index} onPress={() => {this.onPress(index)}} /> }

y reemplace onPress con

 onPress = (index) => { this.setState({ selectedIndex: index }); }

y actualice FlatList con accesorios extraData, ya que FlatList debe volver a representarse como

 <FlatList keyExtractor={this._keyExtractor} data={this.state.data} renderItem={this.renderItem} ItemSeparatorComponent={this.renderSeparator} extraData={this.state} />

demostración: https://snack.expo.dev/HkzA9cCSB

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!