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

241
Views
Cómo editar un artículo en una Flatlist

Hice una lista plana y un botón de edición que puede abrir un modal a una entrada de texto y rastrear la clave del elemento específico. ¿Cómo actualizo este elemento en Flatlist con la entrada de texto diferente? Intenté hacer algo con setJournal pero no sé cómo devolverlo con la entrada editada.

 export default function HomeScreen({ navigation }) { const [journal, setJournal] = useState([ { date: "12-dec22", entry: "good day", key: "1" }, { date: "12-dec22", entry: "bad day", key: "2" }, ]); const [editModal, setEditModal] = useState(false); const handleEditPress = (key) => { const currentJournal = journal.find((journn) => { return journn.key === key; }); setEditModal(true); console.log(key); }; const updateEntry = (key, entry) => { if (journal.key === key) { setJournal((currentJournal) => { return [entry, ...currentJournal]; }); } else {} journal = journal.map((journn) => journn.key === key ? { ...journn, ...updateEntry } : journn ); }; return ( <View> <Modal visible={editModal}> <TextInput onChangeText={() => updateEntry()} /> <MaterialIcons name="close" onPress={() => setEditModal(false)} /> </Modal> <View> <MaterialIcons onPress={() => setModalOpen(true)}/> <MaterialIcons onPress={() => deleteAll()} /> </View> <FlatList data={journal} renderItem={({ item }) => ( <View style={styles.flatlistView}> <TouchableOpacity> <View> <MaterialIcons onPress={() => handleEditPress(item.key)}/> </View> </TouchableOpacity> </View> )} /> </View> ); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

const handleEditPress = (editedField, itemKey)=>{

journal.filter((currentItem.key)=>{(currentItem.key) === itemKey})).text = editedField

setDiario(diario) }

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!