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

148
Views
Reaccionar extracción nativa para actualizar no funciona

Estoy tratando de agregar pull para actualizar para obtener mis datos de mi API, pero no funciona y no puedo encontrar el problema dentro del código:

 const[refresh,setRefresh]=useState(true) const onRefresh=()=>{ try{ axios .get('http://192.168.1.17:8000/File/') .then((response)=> { setFile(response.data); setFilteredFile(response.data) setEmpty(false) setRefresh(false); })} catch(error){console.log(error) } }

 useEffect(()=>{ onRefresh() },[])

 <FlatList style={DocumentStyle.flatstyle} keyExtractor={(item)=>item['id']} data={filteredfile} renderItem={renderItem} onRefresh={()=>onRefresh()} refreshing={refresh} />

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

0

No se preocupen por mí, no he vuelto a establecer mi actualización en verdadero después de que useEffect lo establezca en falso

about 4 years ago · Juan Pablo Isaza Report

0

El error se debe a que no importó useState, pero también necesita importar useEffect. Tampoco veo dónde se están utilizando algunos de los accesorios que pasaste a FlatList. Pero aquí hay una muestra de trabajo:

 import {useState, useEffect} from 'react'; const FlatList = ({file, refreshing, onRefresh}) => { return ( <div> <p>{file}</p> <button onClick={() => onRefresh(2)}>Load another todo</button> </div> ) } export default function App() { const [refresh, setRefresh] = useState(true); const [file, setFile] = useState(''); useEffect(() => onRefresh(), []); const onRefresh = (id=1) => { try { fetch(`https://jsonplaceholder.typicode.com/todos/${id}`) .then(response => response.json()) .then(json => { console.log(json) setFile(JSON.stringify(json)) setRefresh(false); }) } catch(error) { console.log(error); } } return <FlatList file={file} refreshing={refresh} onRefresh={onRefresh} /> }
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!