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

120
Views
Mi estado cambia pero los componentes desaparecen cuando actualizo mi estado en React Native ¿Cómo solucionar esto?
const DetailedSearchScreen=({ navigation })=> { const mydefauthor='no'; const mydeftitle='data'; var [dataset, setDataset]=useState({data:[{Author:'Deneme', Title:'yapiyorum'}]}); return ( <ScrollView contentContainerStyle={styles.container}> <TextInput onChangeText={text=>det_author=text} placeholder="Enter Author" style={styles.item_style} onClick={()=>{ console.log(dataset, "You are the hero!"); }}/> <TextInput onChangeText={text=>det_keyword=text} placeholder="Enter Keyword" style={styles.item_style}/> <TextInput onChangeText={text=>det_year=parseInt(text)} placeholder="Year" style={styles.item_style}/> <TextInput onChangeText={text=>det_sub_date=text} placeholder="Enter Submission Date As Year-Month-Day" style={styles.item_style}/> <TouchableOpacity onPress={()=>{ var data_=make_search(); console.log("Data info: ",dataset); var item={}; item['data']=data_; setDataset(Object.assign({...dataset, ...item})); console.log(dataset, "Yine mi olmadı be"); }} style={styles.button}><Text>Search</Text></TouchableOpacity> <View> { dataset['data'].map((item, key)=>{ console.log(item); return( <Text>{item['Author']}</Text> ); })} </View> </ScrollView> ); }

parte del código es así, cuando leo el resultado de console.log, muestra que el estado ha cambiado pero mis componentes mapeados desaparecen cuando actualizo el estado

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No ingresó su accesorio clave en el elemento Texto. Deberías

 <Text key={key}> ... </Text>

También aquí está utilizando el índice de matriz como clave y podría causar errores.

Debe usar algo que sea único para esos datos y que no cambie (título o autor si son únicos e inmutables).

La mejor opción sería tener una identificación única.

https://reactjs.org/docs/lists-and-keys.html

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!